Option Explicit
Dim a As Integer
Dim b As Integer
Dim c As String
Dim d As Integer
Dim zongshu As Integer
Dim zhengque As Integer
Dim cuowu As Integer
Dim chengji As Integer
Private Sub Form_Load()
zongshu = 0
zhengque = 0
cuowu = 0
chengji = 0
chuti
End Sub
Sub chuti()
Dim fuhao(4) As String
fuhao(0) = "+"
fuhao(1) = "-"
fuhao(2) = "*"
fuhao(3) = "/"
Randomize
a = Int(Rnd * 100)
b = Int(Rnd * 99)+1
c = fuhao(Int(UBound(fuhao) * Rnd))
Label1.Caption = a & c & b & "="
Select Case c
Case "+"
d = a + b
Case "-"
d = a - b
Case "*"
d = a * b
Case "/"
d = a / b
End Select
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Int(Text1.Text) = d Then
zhengque = zhengque + 1
Text2.Text = Text2.Text & Label1.Caption & d & Space(2) & "√" & vbCrLf
Else
cuowu = cuowu + 1
Text2.Text = Text2.Text & Label1.Caption & d & Space(2) & "×" & vbCrLf
End If
zongshu = zongshu + 1
chengji = zhengque * 5 ' 按20道题100分计算
Text3.Text = zongshu
Text4.Text = zhengque
Text5.Text = cuowu
Text6.Text = chengji
End If
chuti
End Sub