Dim c As String
Dim f1 As Double, f2 As Double, f As Double, x As Integer
Private Sub Command1_Click()
Text1.Text = 0
c = ""
f1 = 0
f2 = 0
f = 0
End Sub
Private Sub Command10_Click()
Dim c2 As String
c2 = 2
c = c + c2
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command11_Click()
Dim c3 As String
c3 = 3
c = c + c3
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command12_Click()
Dim c0 As String
c0 = 0
If Val(Text1.Text) = 0 Then
Text1.Text = 0
c = ""
Else
c = c + c0
Text1.Text = c
End If
f1 = Val(c)
End Sub
Private Sub Command13_Click()
f1 = -f1
Text1.Text = f1
End Sub
Private Sub Command14_Click()
Dim c10 As String
If f = 0 Then
c10 = "."
If Text1.Text = 0 Then
c = "0."
Text1.Text = c
Else
c = c + c10
Text1.Text = c
f1 = Val(c)
End If
Else
c = "0."
Text1.Text = c
End If
End Sub
Private Sub Command15_Click()
x = 4
c = ""
f2 = Val(Text1.Text)
End Sub
Private Sub Command16_Click()
x = 3
c = ""
f2 = Val(Text1.Text)
End Sub
Private Sub Command17_Click()
x = 1
c = ""
f2 = Val(Text1.Text)
End Sub
Private Sub Command18_Click()
x = 2
c = ""
f2 = Val(Text1.Text)
End Sub
Private Sub Command19_Click()
f = Sqr(Text1.Text)
Text1.Text = f
c = ""
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command20_Click()
f = Val(Text1.Text) * Val(Text1.Text)
Text1.Text = f
c = ""
End Sub
Private Sub Command21_Click()
f = Val(Text1.Text) * Val(Text1.Text) * Val(Text1.Text)
Text1.Text = f
c = ""
End Sub
Private Sub Command22_Click()
Select Case x
Case 1
f = f1 + f2
Text1.Text = f
Case 2
f = f2 - f1
Text1.Text = f
Case 3
f = f2 * f1
Text1.Text = f
Case 4
f = f2 / f1
Text1.Text = f
End Select
End Sub
Private Sub Command3_Click()
Dim c7 As String
c7 = "7"
c = c + c7
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command4_Click()
Dim c8 As String
c8 = 8
c = c + c8
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command5_Click()
Dim c9 As String
c9 = 9
c = c + c9
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command6_Click()
Dim c4 As String
c4 = 4
c = c + c4
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command7_Click()
Dim c5 As String
c5 = 5
c = c + c5
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command8_Click()
Dim c6 As String
c6 = 6
c = c + c6
Text1.Text = c
f1 = Val(c)
End Sub
Private Sub Command9_Click()
Dim c1 As String
c1 = 1
c = c + c1
Text1.Text = c
f1 = Val(c)
End Sub
这个程序是自己第一次学 VB写的,很多都是可以改进的!