请学霸大佬帮我解决一下这个vb编程,谢谢!
发布网友
发布时间:2024-01-13 14:53
我来回答
共1个回答
热心网友
时间:2024-01-13 21:13
Dim n As Integer, t As Integer, strS As String
Private Sub Command1_Click()
Timer1.Interval = 100
End Sub
Private Sub Form_Load()
strS = "He has made a string of outspoken and sometimes provocative speeches in recent."
Label1.BackStyle = 1
End Sub
Private Sub Timer1_Timer()
n = n + 1
Label1.Caption = Label1.Caption + Mid(strS, n, 1)
If n = Len(strS) Then
Timer1.Interval = 0
Timer2.Interval = 100
End If
End Sub
Private Sub Timer2_Timer()
If t Mod 2 = 0 Then
Label1.BackColor = vbBlack
Else
Label1.BackColor = vbWhite
End If
t = t + 1
End SubPrivate Sub Form_Load()
Randomize
Me.AutoRedraw = True
Dim Operator As String, Num1 As Integer, Num2 As Integer, CalculateResult As Integer, InputResult As Integer
For i = 1 To 10
Num1 = Int(Rnd * 10): Num2 = Int(Rnd * 10)
n = Int(Rnd * 4 + 1)
Select Case n
Case 1
Operator = "+"
InputResult = InputBox("第(" & i & ")题 " & Num1 & Operator & Num2 & "=", "四则运算", 0)
Print "第(" & i & ")题",
Print Num1 & Operator & Num2 & "=" & InputResult,
CalculateResult = Num1 + Num2
Case 2
Operator = "-"
InputResult = InputBox("第(" & i & ")题 " & Num1 & Operator & Num2 & "=", "四则运算", 0)
Print "第(" & i & ")题 ",
Print Num1 & Operator & Num2 & "=" & InputResult,
CalculateResult = Num1 - Num2
Case 3
Operator = "*"
InputResult = InputBox("第(" & i & ")题 " & Num1 & Operator & Num2 & "=", "四则运算", 0)
Print "第(" & i & ")题",
Print Num1 & Operator & Num2 & "=" & InputResult,
CalculateResult = Num1 * Num2
Case 4
If Num2 <> 0 Then
Operator = "/"
CalculateResult = Num1 / Num2
Else
Operator = "*"
CalculateResult = Num1 * Num2
End If
InputResult = InputBox("第(" & i & ")题 " & Num1 & Operator & Num2 & "=", "四则运算", 0)
Print "第(" & i & ")题",
Print Num1 & Operator & Num2 & "=" & InputResult,
End Select
If CalculateResult = InputResult Then
Print "√"
Else
Print "×"
End If
Next i
End Sub