level 7
我欣飞扬520
楼主

Option ExplicitDim exp As String, result As Single, nok As Integer, nerror As IntegerDim op As Integer, num1 As Integer, num2 As Integer, nop As StringPrivate Sub Command1_Click()If Command1.Caption = "&s开始" ThenTimer1.Enabled = TrueCommand1.Caption = "&c暂停"ElseTimer1.Enabled = FalseCommand1.Caption = "&s开始"Text2.SetFocusEnd IfEnd Sub
Private Sub Command2_Click()Picture1.Print String(20, "◆")Picture1.Print "一共计算了"; nok + nerror; "题"Picture1.Print "得分" & Int(nok / (nerror + nok) * 100)End Sub
Private Sub Command3_Click()EndEnd Sub
Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Val(Text2) = result Then Picture1.Print exp; result; "√" nok = nok + 1 Else Picture1.Print exp; result; "×" nerror = nerror + 1 End IfText2 = ""End IfEnd Sub
Private Sub Timer1_Timer()RandomizeDim op As Integernum1 = Int(Rnd * (9)) + 1num2 = Int(Rnd * (9)) + 1op = Int(Rnd * (4)) + 1 Text1.ForeColor = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)Text2.ForeColor = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
If Val(Text1) < 0 Then Timer1.Enabled = False Text1.Text = "" Text1.SetFocus ElseText1 = Str(Val(Text1) - 1)End IfSelect Case op Case 1 nop = "+" result = num1 + num2 Case 2 nop = "-" result = num1 - num2 Case 3 nop = "*" result = num1 * num2 Case Else nop = "/" result = num1 / num2End Select exp = num1 & nop & num2 & "="Label2.Caption = expEnd Sub