Private Sub Command1_Click()
Picture1.Print "共计算" & (r + w) & "道题,得分" & Int((r / w + r) * 100)
End Sub
Private Sub Form_Load()
Randomize
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '按下回车
If Val(Text1.Text) <> y Then
Picture1.Print Label1.Caption; Text1.Text; Tab(10); "×"
r = r + 1
Else
Picture1.Print Label1.Caption; Text1.Text; Tab(10); "√"
w = w + 1
End If
Text1.Text = ""
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
Dim n1%, n2%, fh$, x%
n1 = Int(Rnd * 10 + 1) '产生第一个数
n2 = Int(Rnd * 10 + 1) '产生第二个数
x = Int(Rnd * 4 + 1) '产生运算符号
If x = 1 Then
fh = "+"
y = n1 + n2
ElseIf x = 2 Then
fh = "-"
y = n1 - n2
ElseIf x = 3 Then
fh = "*"
y = n1 * n2
ElseIf x = 4 Then
fh = "/"
y = n1 / n2
End If
Label1.Caption = n1 & fh & n2 & "="
Timer1.Enabled = False
Text1.SetFocus
End Sub
上面程序是计算机随机产生1-10 的数和运算符 + - * %
当学生输入答案 计算机判断答案并给出分数
大家看下 错在哪里
我觉得没有错