求VB高手帮设计一个“自动出题”程序!

用label出题,十以内加减法,结果是点击数字0~18选择。好的话有加分!!!
还要用到timer控件

‘写完了,新鲜出炉……
'先添加6个label,然后一个command1(按钮),然后一个timer,最后在command1的index项填上0,就可以运行了。PS:控件随便放,位置已经定好了。6个框用作题目的显示,正确与错误的技术,以及计时。没了,就这样。

Private Sub Command1_Click(Index As Integer)

If Trim(Label6.Caption) = "+" Then

If Int(Label1.Caption) + Int(Label2.Caption) = Index Then
Label4.Caption = Label4.Caption + 1
Else
Label5.Caption = Label5.Caption + 1
MsgBox "好像不对哎," & Label1.Caption & Label6.Caption & Label2.Caption & "=" & Int(Label1.Caption) + Int(Label2.Caption)
End If
ElseIf Trim(Label6.Caption) = "-" Then

If Int(Label1.Caption) - Int(Label2.Caption) = Index Then
Label4.Caption = Label4.Caption + 1
Else
Label5.Caption = Label5.Caption + 1
MsgBox "好像不对哎," & Label1.Caption & Label6.Caption & Label2.Caption & "=" & Int(Label1.Caption) - Int(Label2.Caption)
End If
End If

Call RndNum

End Sub

Private Sub Form_Load()
Dim i As Integer

Me.Width = 8295
Me.Height = 5790

Label1.Height = 495
Label2.Height = Label1.Height
Label3.Height = Label1.Height
Label4.Height = Label1.Height
Label5.Height = Label1.Height
Label6.Height = Label1.Height

Label1.Width = 255
Label2.Width = 255
Label6.Width = 255
Label3.Width = 1215
Label4.Width = 1215
Label5.Width = 1215

Label1.Top = 480
Label2.Top = 480
Label6.Top = 480
Label3.Top = 480
Label4.Top = 1200
Label5.Top = 1200

Label4.Left = 4200
Label5.Left = 6240
Label3.Left = 4200
Label1.Left = 600
Label6.Left = 960
Label2.Left = 1320

With Command1(0)
.Width = 1215
.Height = 495
.Top = 1920
.Left = 600
.Caption = 0
End With

Timer1.Interval = 1000
Timer1.Enabled = True

For i = 1 To 18
Load Command1(i)

If i <= 4 Then
Command1(i).Left = Command1(i - 1).Left + 1500
Else
Command1(i).Left = Command1(i - 5).Left
End If

Command1(i).Top = (i \ 5) * 550 + Command1(0).Top
Command1(i).Visible = True
Command1(i).Caption = i
Next i

Call RndNum

Label4.Caption = 0
Label5.Caption = 0
End Sub

Private Sub Timer1_Timer()
Static i As Integer
i = i + 1
Label3.Caption = i & "秒"
End Sub

Private Sub RndNum()
Randomize
Label1.Caption = Mid(Rnd(Right(Time$, 2)), 3, 1)
Label2.Caption = Mid(Rnd(Right(Time$, 2)), 3, 1)
Label6.Caption = "+"
If Label1.Caption < Label2.Caption Then
i = Label2.Caption
Label2.Caption = Label1.Caption
Label1.Caption = i
End If

If Right(Rnd(Right(Time$, 1)), 1) Mod 2 = 0 Then
Label6.Caption = "+"
Else
Label6.Caption = "-"
End If
End Sub

参考资料:写得好长,您自己改改也行

温馨提示:内容为网友见解,仅供参考
第1个回答  2012-06-28
有成品。。。。
相似回答