发布网友 发布时间:2022-04-23 09:42
共1个回答
热心网友 时间:2023-10-09 21:00
Dim a As Integer
Dim b As Integer, c As Integer
Private Sub Text1_Change() '有点懒
If IsNumeric(Text1) = False Then
MsgBox "不是数字,请输入数字", 0, "提示"
Text1.SetFocus
Text1.SelStart = Len(Text1)
SendKeys "{BACKSPACE}"
End If
End Sub
Private Sub Command1_Click()
If a = Val(Text1.Text) Then
MsgBox ("正确")
Command2.Visible = True
Command1.Visible = False
Text1.Text = ""
Label1.Caption = ""
Text1.Visible = False
Else
MsgBox ("不对")
Text1.Text = ""
End If
End Sub
Private Sub Command2_Click()
b = Int(Rnd * (100 - 1 + 1)) + 1
c = Int(Rnd * (100 - 1 + 1)) + 1
a = b + c
Label1.Caption = b & " + " & c & "= "
Command2.Visible = False
Command1.Visible = True
Text1.Visible = True
End Sub