第1个回答 2015-05-02
Option Base 1
Dim a As Integer, b As Integer, c As Integer, n As Integer
Private Sub Command1_Click()
s = "+-×÷"
Text1.Text = ""
n = Int(Rnd(1) * 4) + 1
a = Int(9 * Rnd(1)) + 1
b = Int(9 * Rnd(1)) + 1
If n = 2 And a < b Then t = a: a = b: b = a
If n = 4 Then c = b: b = a: a = a * c
Label1.Caption = a & Mid(s, n, 1) & b & "="
End Sub
Private Sub Command2_Click()
Select Case n
Case 1
c = a + b
Case 2
c = a - b
Case 3
c = a * b
Case 4
c = a / b
End Select
If c = CInt(Text1.Text) Then
MsgBox ("对了,您真棒!")
Else
MsgBox ("错了,再努力!")
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End If
End Sub
Private Sub Form_Load()
Label1.Caption = ""
Text1.Text = ""
Label1.FontSize = 20
Text1.FontSize = 20
End Sub