vb题,三个标签,一个文本框,两个命令按钮,编写一计算机自动出题并判断对错的程序,单击出题按钮,
在标签中显示题面(有加减乘除四种运算)在文本框中输入答案然后单击判断按钮即可弹出提示正确或错误的消息框...
在标签中显示题面(有加减乘除四种运算)在文本框中输入答案然后单击判断按钮即可弹出提示正确或错误的消息框
展开
展开全部
Private Sub command1_click() '出题
Randomize
Label1 = Int(Rnd * 9) + 1 '如果要两位数就把9改成99
Randomize
Label3 = Int(Rnd * 9) + 1
Select Case Int(Rnd * 4) + 1
Case 1
Label2 = "+"
Case 2
Label2 = "-"
Case 3
Label2 = "×"
Case 4
Label2 = "÷"
End Select
End Sub
Private Sub Command2_Click()
Select Case Label2.Caption
Case "+"
If Text1 = CInt(Label1) + CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "-"
If Text1 = CInt(Label1) - CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "×"
If Text1 = CInt(Label1) * CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "÷"
If Text1 = CInt(Label1) / CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
End Select
End Sub
Randomize
Label1 = Int(Rnd * 9) + 1 '如果要两位数就把9改成99
Randomize
Label3 = Int(Rnd * 9) + 1
Select Case Int(Rnd * 4) + 1
Case 1
Label2 = "+"
Case 2
Label2 = "-"
Case 3
Label2 = "×"
Case 4
Label2 = "÷"
End Select
End Sub
Private Sub Command2_Click()
Select Case Label2.Caption
Case "+"
If Text1 = CInt(Label1) + CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "-"
If Text1 = CInt(Label1) - CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "×"
If Text1 = CInt(Label1) * CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
Case "÷"
If Text1 = CInt(Label1) / CInt(Label3) Then
MsgBox "正确"
Else
MsgBox "错误"
End If
End Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询