用VB实现,编写一个100以内,可以自动出题的加法练习程序。(100以内的随机整数为INT(RND()*100))

2024-12-12 13:00:22
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim a, b As Integer
Dim s As String
Randomize
a = Int(Rnd() * 100)
b = Int(Rnd() * 100)
s = CStr(a)
Label1.Caption = s
s = CStr(b)
Label2.Caption = s

End Sub

Private Sub Command2_Click()
Dim a, b, c As Integer
a = CInt(Label1.Caption)
b = CInt(Label2.Caption)
c = CInt(Text1.Text)
If (a + b = c) Then
Command2.Caption = "正确"
Else
Command2.Caption = "错误"
End If

End Sub

Private Sub Form_Load()
Label1.Caption = ""
Label2.Caption = ""
Text1.Text = ""

End Sub