4.
设计一个标签,内容为随机产生的10以内的加减乘法算式,另设计一个文本框,可以输入运算结果,当用户按回车键时,判断运算结果是否正确、文本框内容是否数字,以输出不同的msgbox提示,并根据用户的按键决定是否重做或重新出题,最后设计两个按钮分别实现程序结束和记分功能(可以参照课件上的程序,注意其中要修改的部分)
Option Explicit
Public p#, a#, b#, c#
Private Sub Command1_Click()
a = Int(Rnd * 10 + 1)
b = Int(Rnd * 10 + 1)
c = Int(Rnd * 4 + 1)
Select Case c
Case 1
Label2 = a & "+" & b
p = a + b
Case 2
Label2 = a & "-" & b
p = a - b
Case 3
Label2 = a & "*" & b
p = a * b
Case 4
Label2 = a & "/" & b
p = a / b
End Select
End Sub
Private Sub Command2_Click()
If Not IsNumeric(Text1.Text) Then
MsgBox "please input a number", 16, "error"
If Text1.Text = answer Then
Print "correct"
Else
Print "error the answer is"; answer
End If
End If
End Sub
If Not IsNumeric(Text1.Text) Then MsgBox "please input a number", 16, "error" If Text1.Text = answer Then 上面的最后一行的上面应该加一个elseIf Not IsNumeric(Text1.Text) Then MsgBox "please input a number", 16, "error" elseIf Text1.Text = answer Then...
If Text1.Text = answer Then Print "correct" Else Print "error the answer is"; answer End If 改为 If val(Text1.Text) = p Then Print "correct" Else Print "error the a...