早教吧作业答案频道 -->其他-->
vb,1-100整数加减法自动出题器,急用!要求:1,按回车出随机数,输入答案就显示对错(诸如你真聪明,别灰心继续努力之类的),并清空答案框随机出下一题.2,计时器计时,每两分钟做出一次总结并
题目详情
vb,1-100整数加减法自动出题器,急用!
要求:
1,按回车出随机数,输入答案就显示对错(诸如你真聪明,别灰心继续努力之类的),并清空答案框随机出下一题.
2,计时器计时,每两分钟做出一次总结并列出总结数据:做的总题数,对错题数.
要求:
1,按回车出随机数,输入答案就显示对错(诸如你真聪明,别灰心继续努力之类的),并清空答案框随机出下一题.
2,计时器计时,每两分钟做出一次总结并列出总结数据:做的总题数,对错题数.
▼优质解答
答案和解析
添加2个label控件,label1显示算式,label2显示进行时间
添加1个text控件,用于输入结果
添加1个command控件,用于开始
添加1个timer控件,用于计时
程序如下,已经过测试
Option Explicit
Dim starttime As Long,sum As Integer,tOK As Integer,tBad As Integer
Dim result As Integer
Private Sub Command1_Click()
Command1.Enabled = False
Command1.Caption = "运行中"
Text1.Enabled = True
Call Random
sum = 0
tOK = 0
tBad = 0
starttime = Timer()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Label1.Caption = ""
Text1.Text = ""
Text1.Enabled = False
Command1.Caption = "开始计时"
Timer1.Interval = 100
Timer1.Enabled = False
Label2.Caption = ""
End Sub
Private Sub Random()
Dim a,b,c
Randomize
sum = sum + 1
a = Int(Rnd * 100 + 1)
b = Int(Rnd * 2)
c = Int(Rnd * 100 + 1)
If b = 1 Then
result = a + c
Label1.Caption = a & " + " & c & " ="
Else
If a < c Then
Label1.Caption = c & " - " & a & " ="
Else
Label1.Caption = a & " - " & c & " ="
End If
result = Abs(a - c)
End If
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim d As Integer
d = -1
If KeyAscii = 13 Then
If IsNumeric(Trim(Text1.Text)) Then d = Val(Text1.Text)
If d = result Then
MsgBox "你真聪明",vbOKOnly
tOK = tOK + 1
Else
MsgBox "别灰心继续努力"
tBad = tBad + 1
End If
Call Random
End If
End Sub
Private Sub Timer1_Timer()
Label2.Caption = "已过去 " & Format(Timer() - starttime,"0.00") & " 秒"
If Timer() - starttime >= 120 Then
Timer1.Enabled = False
Text1.Enabled = False
Command1.Enabled = True
Command1.Caption = "开始计时"
Label2.Caption = ""
MsgBox "总题数:" & sum & vbCrLf & "对 " & tOK & " 题" & vbCrLf & "错 " & tBad & " 题"
End If
End Sub
添加1个text控件,用于输入结果
添加1个command控件,用于开始
添加1个timer控件,用于计时
程序如下,已经过测试
Option Explicit
Dim starttime As Long,sum As Integer,tOK As Integer,tBad As Integer
Dim result As Integer
Private Sub Command1_Click()
Command1.Enabled = False
Command1.Caption = "运行中"
Text1.Enabled = True
Call Random
sum = 0
tOK = 0
tBad = 0
starttime = Timer()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Label1.Caption = ""
Text1.Text = ""
Text1.Enabled = False
Command1.Caption = "开始计时"
Timer1.Interval = 100
Timer1.Enabled = False
Label2.Caption = ""
End Sub
Private Sub Random()
Dim a,b,c
Randomize
sum = sum + 1
a = Int(Rnd * 100 + 1)
b = Int(Rnd * 2)
c = Int(Rnd * 100 + 1)
If b = 1 Then
result = a + c
Label1.Caption = a & " + " & c & " ="
Else
If a < c Then
Label1.Caption = c & " - " & a & " ="
Else
Label1.Caption = a & " - " & c & " ="
End If
result = Abs(a - c)
End If
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim d As Integer
d = -1
If KeyAscii = 13 Then
If IsNumeric(Trim(Text1.Text)) Then d = Val(Text1.Text)
If d = result Then
MsgBox "你真聪明",vbOKOnly
tOK = tOK + 1
Else
MsgBox "别灰心继续努力"
tBad = tBad + 1
End If
Call Random
End If
End Sub
Private Sub Timer1_Timer()
Label2.Caption = "已过去 " & Format(Timer() - starttime,"0.00") & " 秒"
If Timer() - starttime >= 120 Then
Timer1.Enabled = False
Text1.Enabled = False
Command1.Enabled = True
Command1.Caption = "开始计时"
Label2.Caption = ""
MsgBox "总题数:" & sum & vbCrLf & "对 " & tOK & " 题" & vbCrLf & "错 " & tBad & " 题"
End If
End Sub
看了 vb,1-100整数加减法自...的网友还看了以下:
汽车、电机车一般要使用铅酸蓄电池.某铅酸蓄电池用的酸溶液是溶质质量分数为28%的稀硫酸,现用溶质质 2020-04-09 …
汽车,电动车一般要使用铅酸蓄电池.某铅酸蓄电池用的酸溶液溶质质量分数为30%的稀硫酸,先用1L溶质 2020-05-16 …
客货两车从甲乙两地同时相向而行,客车1时行65KM,货车一时行60KM,在具中点十米处相遇,甲乙两 2020-05-16 …
火车,人类的交通工具,1804年由英国的矿山技师德里维斯克利用瓦特的蒸汽机造出了世界上第一台蒸汽机车 2020-12-09 …
一机车汽笛频率为750Hz,机车以时速90公里远离静止的观察者.观察者听到的声音的频率是. 2020-12-13 …
由蒸汽机车一分钟行驶多少米?高铁呢?急死了! 2020-12-13 …
高一物理(请说明理由)质量M=500t的机车,一恒定的功率从禁止出发,经过实践t=5min在水平路面 2020-12-13 …
额定功率为P=60kW的机车质量为m=40t,由静止以加速度a=0.5m/s2起动,运动过程中所受摩 2020-12-13 …
19世纪末的中国面临瓜分豆剖的民族危机。当时先进的中国人对如何挽救民族危机这一时代课题做出的最符合当 2020-12-26 …
19世纪末的中国面临瓜分豆剖的民族危机。当时先进的中国人对如何挽救民族危机这一时代课题做出的最符合当 2020-12-26 …