代码是这样的,大家帮我看一下
Dim m As Integer
Dim acount, sum As Integer
Private Sub Command1_Click()
Label2.Visible = True
Text1.Visible = True
Text1.SetFocus
Randomize
m = Int((100 * Rnd) + 1)
Command1.Enabled = False
acount = 0
End Sub
Private Sub Form_Load()
Label2.Visible = False
Text1.Visible = False
sum = 0
account = 0
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim n As Integer
If KeyCode = 13 Then
n = Val(Trim(Text1.Text))
If n > m Then
MsgBox "你输入的数据过大"
Text1.Text = ""
Text1.SetFocus
acount = account + 1
ElseIf n < m Then
MsgBox "你输入的数据过小"
Text1.Text = ""
Text1.SetFocus
acount = account + 1
Else
If n = m Then
MsgBox "输入正确"
sum = sum + 1
Text1.Text = ""
Text1.SetFocus
Command1.Enabled = True
End If
End If
End If
If acount >= 3 Then Unload Me
If sum >= 10 Then MsgBox "你真是神算啊"
End Sub
Dim m As Integer
Dim acount, sum As Integer
Private Sub Command1_Click()
Label2.Visible = True
Text1.Visible = True
Text1.SetFocus
Randomize
m = Int((100 * Rnd) + 1)
Command1.Enabled = False
acount = 0
End Sub
Private Sub Form_Load()
Label2.Visible = False
Text1.Visible = False
sum = 0
account = 0
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim n As Integer
If KeyCode = 13 Then
n = Val(Trim(Text1.Text))
If n > m Then
MsgBox "你输入的数据过大"
Text1.Text = ""
Text1.SetFocus
acount = account + 1
ElseIf n < m Then
MsgBox "你输入的数据过小"
Text1.Text = ""
Text1.SetFocus
acount = account + 1
Else
If n = m Then
MsgBox "输入正确"
sum = sum + 1
Text1.Text = ""
Text1.SetFocus
Command1.Enabled = True
End If
End If
End If
If acount >= 3 Then Unload Me
If sum >= 10 Then MsgBox "你真是神算啊"
End Sub