题目是:程序运行是,单击“开始”按钮,每秒钟产生3个1到6的随机数字 单击“暂停”按钮,终止随机数的产生。 随机数的代码我会,但不知道计时器的代码怎么写 Private Sub Command1_Click() Cls Dim a(3) As Integer For l = 1 To 3 x = Int(Rnd * 10)... 题目是:程序运行是,单击“开始”按钮,每秒钟产生3个1到6的随机数字
单击“暂停”按钮,终止随机数的产生。
随机数的代码我会,但不知道计时器的代码怎么写
Private Sub Command1_Click()
Cls
Dim a(3) As Integer
For l = 1 To 3
x = Int(Rnd * 10)
Debug.Print x
For i = 1 To 6
If i = x Then
Exit For
End If
Next i
Next l
Label1.Caption = Int((Rnd * 6) + 1)
Label2.Caption = Int((Rnd * 6) + 1)
Label3.Caption = Int((Rnd * 6) + 1)
End Sub
Private Sub Timer1_Timer()
End Sub
谁能帮写下代码啊
Private Sub Command1_Click()
Cls
Dim a(3) As Integer
For l = 1 To 3
Randomize
x = Int(Rnd * 10)
Debug.Print x
For i = 1 To 6
If i = x Then
Exit For
End If
Next i
Next l
Label1.Caption = Int((Rnd * 6) + 1)
Label2.Caption = Int((Rnd * 6) + 1)
Label3.Caption = Int((Rnd * 6) + 1)
End Sub
Private Sub Command2_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Command2.Caption = "暂停"
Else
Command2.Caption = "开始"
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = "1000"
Command2.Caption = "开始"
End Sub
Private Sub Form_Load()
Timer1.Enabled = False: Timer1.Interval = 1000
Command1.Caption = "开始": Command2.Caption = "暂停"
End Sub
'开始按钮
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
'暂停按钮
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
'将你原来的 Command1_Click 中的代码放到 Timer1_Timer 中
Private Sub Timer1_Timer()
Cls
Dim a(3) As Integer
For l = 1 To 3
x = Int(Rnd * 10)
Debug.Print x
For i = 1 To 6
If i = x Then
Exit For
End If
Next i
Next l
Label1.Caption = Int((Rnd * 6) + 1)
Label2.Caption = Int((Rnd * 6) + 1)
Label3.Caption = Int((Rnd * 6) + 1)
End Sub
Private Sub Timer1_Timer()
Dim a(3) As Integer
For l = 1 To 3
x = Int(Rnd * 10)
Debug.Print x
For i = 1 To 6
If i = x Then
Exit For
End If
Next i
Next l
Label1.Caption = Int((Rnd * 6) + 1)
Label2.Caption = Int((Rnd * 6) + 1)
Label3.Caption = Int((Rnd * 6) + 1)
End Sub