猜一猜源代码:
Private Sub Command1_Click()
a = Text1.Text
a = a + 2
a = a + 3
If a = Text2.Text Then
MsgBox "Successfully!"
Else
MsgBox "UnSuccessfully"
End If
End Sub
建议你改成:
Private Sub Command1_Click()
Dim dTemp As Double
dTemp = Val(Text1.Text)
dTemp = dTemp + 2 + 3
If dTemp = Val(Text2.Text) Then
MsgBox "Successfully!"
Else
MsgBox "UnSuccessfully"
End If
End Sub
这样程序就不会那么容易崩溃了
还可以改成这样:
Private Sub Command1_Click()
'Dim dTemp As Double
On Error GoTo ErrorProcess
a = Text1.Text
a = a + 2
a = a + 3
If a = Text2.Text Then
MsgBox "Successfully!"
Else
MsgBox "UnSuccessfully"
End If
Exit Sub
ErrorProcess:
MsgBox "Find a mistake,code:" & Err.Number & " - " & Error, vbExclamation, "Error"
End Sub