Private Sub Command16_Click()
If num = 1 Then
——————
所有的num没有赋值
类似修改如下:
Private Sub Command2_Click()
num2 = Text1
num=2
Text1 = ""
End Sub
Option Compare DatabaseOption Explicit
Dim num1 As LongDim yunsuan As Integer
Private Sub Command4_Click()
Me.Text2 = Me.Text2 + "1"
End Sub
Private Sub Command5_Click()
Me.Text2 = Me.Text2 + "2"
End Sub
Private Sub Command6_Click()
Me.Text2 = Me.Text2 + "3"
End Sub
Private Sub Command7_Click()
Me.Text2 = Me.Text2 + "4"
End Sub
Private Sub Command8_Click()
Me.Text2 = Me.Text2 + "5"
End Sub
Private Sub Command9_Click()
Me.Text2 = Me.Text2 + "6"
End Sub
Private Sub Command10_Click()
Me.Text2 = Me.Text2 + "7"
End Sub
Private Sub Command11_Click()
Me.Text2 = Me.Text2 + "8"
End Sub
Private Sub Command12_Click()
Me.Text2 = Me.Text2 + "9"
End Sub
Private Sub Command13_Click()
Me.Text2 = Me.Text2 + "0"
End Sub
Private Sub Command14_Click()
Me.Text2 = ""
num1 = 0
End Sub
Private Sub Command15_Click()
Dim num2 As Long
num2 = Val(Me.Text2)
Select Case yunsuan
Case 1
num1 = num1 + num2
Case 2
num1 = num1 - num2
Case 3
num1 = num1 * num2
Case 4
If num2 = 0 Then
Me.Text2 = "除零啦"
Exit Sub
Else
num1 = num1 / num2
End If
End Select
Me.Text2 = CStr(num1)
End Sub
Private Sub Command16_Click()
num1 = Val(Me.Text2)
Me.Text2 = ""
yunsuan = 1
Me.Label20.Caption = "+"
End Sub
Private Sub Command17_Click()
num1 = Val(Me.Text2)
Me.Text2 = ""
yunsuan = 2
Me.Label20.Caption = "-"
End Sub
Private Sub Command18_Click()
num1 = Val(Me.Text2)
Me.Text2 = ""
yunsuan = 3
Me.Label20.Caption = "-"
End Sub
Private Sub Command19_Click()
num1 = Val(Me.Text2)
Me.Text2 = ""
yunsuan = 4
Me.Label20.Caption = "/"
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.Text2 = ""
num1 = 0
End Sub
你好,我有现成的代码。。