Dim t1 As Integer, t2 As Integer, sf As Integer, da As Integer
Sub chuti()
Randomize
t1 = Int(Rnd * 90) + 10
t2 = Int(Rnd * (t1 - 9)) + 10
sf = Int(Rnd * 4)
Select Case sf
Case 0
Label1.Caption = t1 & " + " & t2 & " = "
da = t1 + t2
Case 1
Label1.Caption = t1 & " - " & t2 & " = "
da = t1 - t2
Case 2
Label1.Caption = t1 & " * " & t2 & " = "
da = t1 * t2
Case 3
Label1.Caption = t1 & " \ " & t2 & " = "
da = t1 \ t2
End Select
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Me.Show
chuti
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.Text = Text2.Text & Label1.Caption & Val(Text1.Text) & " "
If Val(Text1.Text) = da Then
Text2.Text = Text2.Text & "√"
Else
Text2.Text = Text2.Text & "×"
End If
Text2.Text = Text2.Text & vbCrLf
chuti
End If
End Sub
Text2的MultiLine属性要设为True