字體:小 中 大 | |
|
|
2010/03/15 18:05:46瀏覽409|回應0|推薦0 | |
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim b, a, x, y, a1, a2, j, a11, a22, r As Integer Dim op, ans As String Dim b1, b2, b3, b4 As String FileOpen(1, "C:\title.TXT", OpenMode.Input) Input(1, b1) : Input(1, b2) : Input(1, b3) : Input(1, b4) TextBox1.Text = b1 : TextBox2.Text = b2 : TextBox3.Text = b3 : TextBox4.Text = b4 FileClose() FileOpen(1, "C:\940308.sm", OpenMode.Input) j = 0 Do While Not EOF(1) Input(1, b) : Input(1, a) Input(1, op) Input(1, y) : Input(1, x) Select Case op Case "+" a1 = b * x + a * y a2 = a * x Case "-" a1 = b * x - a * y a2 = a * x Case "*" a1 = b * y a2 = a * x Case "/" a1 = b * x a2 = a * y End Select r = a1 Mod a2 If r = 0 Then ans = a1 / a2 Else a11 = a1 : a22 = a2 Do Until r = 0 a11 = a22 a22 = r r = a11 Mod a22 Loop ans = (a1 / a22) & "/" & (a2 / a22) End If With DataGridView1 .Rows.Add(1) .Item(0, j).Value = b & "/" & a .Item(1, j).Value = op .Item(2, j).Value = y & "/" & x .Item(3, j).Value = ans .Height = j * 38 End With j = j + 1 Me.Height = 150 + j * 35 Loop FileClose() End Sub End Class |
|
( 心情隨筆|心情日記 ) |