Command1_Click()
Timer1.Enabled =(Timer1.Enabled)
s = 0时
H = 0
m = 0的
END SUB
私人Timer1_Timer()
S = S + 1
如果S = 60,M = M + 1:S = 0
如果m = 60 H = H + 1:m = 0的
如果闭念h = 24,H = 0
Label1.Caption = H&“绝简:”&M&“,”&S
END SUB
TIMER1的间隔时间,以等并态裤待1000
TMER1启用开通也为False
两个需要运算的数字可以姿盯用随机函数 rnd 来得到,而四个运算符可以放在数组里面,数组的下标又可以用随机函数取得,则运算符也是随机的,把取得的运算符放在一个标签里 如 label1
然后用选择语句 select 来判断label1.caption 中的运算符 是什么运算符 自己就做什么样的运算 把结果放在一个变量 c 当中
最后用 if 语句判断用户所填的答案与 c 是否相同 相同则正确 不同则错误
代码如下
Dim i As IntegerDim j As Integer
Private Sub Command1_Click()
Text1.Text = Rnd(1) * 1000
Text2.Text = Rnd(1) * 1000
Dim b As Integer
Dim a(4) As String
a(1) = "+"
a(2) = "-"
a(3) = "*"
a(4) = "/"
b = Int((Rnd * 4) + 1)
Label1.Caption = a(b)
Text3.Text = ""
Text3.TabIndex = "0"
End Sub
Private Sub Command2_Click()
Dim c As Double
Select Case Label1.Caption
Case "+"
c 枝拿= Text1.Text + Text2.Text
Case "-"
c = Text1.Text - Text2.Text
Case "*"
迹搭和 c = Text1.Text * Text2.Text
Case "/"
c = Text1.Text * Text2.Text
End Select
If Text1.Text = "" Then
MsgBox "请先选题"
Else
If Text3.Text = "" Then
MsgBox "请先做题"
Else
If Text3.Text = c Then
Label6.Caption = "正确"
i = i + 1
Else
Label6.Caption = "错误" & Space(3) & "正确结果为" & c
j = j + 1
End If
End If
End If
End Sub
Private Sub Command3_Click()
Label7.Caption = i
Label8.Caption = j
End Sub
Private Sub Form_Load()
End Sub
Dim str As String = "", temp As Integer = 0, sum As Integer = 0, x As IntegerDim a(7) As Integer
a(1) = 76
a(2) = 87
a(3) = 90
a(4) = 92
a(5) = 69
a(6) = 82
a(7) = 94
皮启 For i = 1 To 7
For j = 1 To 7 - i
If a(j) > a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
神吵 Next i
For i = 2 To 6
燃瞎如 sum = sum + a(i)
Next
TextBox6.Text = "平均分数是" & sum / 5
另外,程序中的a(1)到a(7),你要将7个text中的数据赋值到其中去
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)