这是一个随机出数学题的程序,可是每次运行时,它出的数学题顺序都是一样的,另外就是倒计时结束时,程序不能结束。希望高手能加点东西,使程序结束时,弹出一个对话框,说明正确率,并能在每次从新运行时出的数学题不一样。还有就是让"出题"和"确定"按钮响应键盘的回车键!谢谢
Dim a, b, c, d, e, f, g As Integer
Private Sub Command2_Click() Timer1.Enabled = True If Command2.Caption = "出题" Then Command2.Caption = "确定" g = Int(Rnd * 5) Select Case g Case 1
a = Int(Rnd * 100) b = Int(Rnd * 100) Label1.Caption = Str(a) + "+" + Str(b) c = a + b Case 2 a = Int(Rnd * 100) b = Int(Rnd * 100) Do While a < b a = Int(Rnd * 100) b = Int(Rnd * 100) Loop Label1.Caption = Str(a) + "-" + Str(b) c = a - b Case 3 a = Int(Rnd * 100) b = Int(Rnd * 100) Do While a > 10 Or b > 10 Or a < 0 Or b < 0 a = Int(Rnd * 100) b = Int(Rnd * 100) Loop Label1.Caption = Str(a) + "*" + Str(b) c = a * b Case 4 a = Int(Rnd * 100) b = Int(Rnd * 100) Do While a < b Or (a Mod b <> 0) Or a < 0 Or a = 0 Or b <= 0 a = Int(Rnd * 100) b = Int(Rnd * 100) Loop Label1.Caption = Str(a) + "/" + Str(b) c = a / b End Select Text1.SetFocus Else If Text1.Text = c Then d = d + 1 End If Label4.Caption = "你答对了" + Str(d) + "道" If Text1.Text <> c Then e = e + 1 End If Label5.Caption = "你答错了" + Str(e) + "道" Text1.Text = "" Command2.Caption = "出题" End If End Sub
Private Sub Command3_Click() Unload Me End Sub
Private Sub Form_Load() f = 100 Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer() If f > 0 Then f = f - 1 Else MsgBox "你一共答对了" + Str(d) + "道" End If
Label2.Caption = f End Sub
[此贴子已经被作者于2005-5-22 12:26:41编辑过]