是不是要上图的效果?刚发现要有序的,在后面补上了有序的代码
无序的代码:
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "开始" Then
CommandButton1.Caption = "停止"
TextBox1.Text = Format(Int(Rnd * 99 + 1), "00")
Else
CommandButton1.Caption = "开始"
End If
End Sub
Private Sub TextBox1_Change()
Do
Call delay(0.1) '在这里调节随机的速度,现在是0.1秒变化一次,根据自己意愿调整
If CommandButton1.Caption = "开始" Then Exit Sub
TextBox1.Text = Format(Int(Rnd * 99 + 1), "00")
Loop
End Sub
Private Sub delay(T As Single)
Dim T1 As Single
T1 = Timer
Do
DoEvents
Loop While Timer - T1 < T
End Sub
有序的代码:
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "开始" Then
CommandButton1.Caption = "停止"
TextBox1.Text = Format(1, "00")
Else
CommandButton1.Caption = "开始"
End If
End Sub
Private Sub TextBox1_Change()
Do
Call delay(0.1)
If CommandButton1.Caption = "开始" Then Exit Sub
If TextBox1.Text = 99 Then
TextBox1.Text = Format(1, "00")
Else
TextBox1.Text = Format(TextBox1.Text + 1, "00")
End If
Loop
End Sub
Private Sub delay(T As Single)
Dim T1 As Single
T1 = Timer
Do
DoEvents
Loop While Timer - T1 < T
End Sub
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "开始" Then
CommandButton1.Caption = "停止"
TextBox1.Text = Format(Int(Rnd * 53 + 1), "00")
TextBox2.Text = Format(Int(Rnd * 8 + 1), "00")
TextBox3.Text = Format(Int(Rnd * 3 + 1), "00")
Else
CommandButton1.Caption = "开始"
End If
End Sub
Private Sub TextBox1_Change()
Do
Call delay(0.1) '在这里调节随机的速度,现在是0.1秒变化一次,根据自己意愿调整
If CommandButton1.Caption = "开始" Then Exit Sub
TextBox1.Text = Format(Int(Rnd * 53 + 1), "00")
TextBox2.Text = Format(Int(Rnd * 8 + 1), "00")
TextBox3.Text = Format(Int(Rnd * 3 + 1), "00")
' TextBox3.Text = Timer
Loop
End Sub
Private Sub delay(T As Single)
Dim T1 As Single
T1 = Timer
Do
DoEvents
Loop While Timer - T1 < T
End Sub
Private Sub TextBox2_Change()
End Sub
联系?