Dim n As Integer, stop_flag As Boolean’设置一个停止信号
Private Sub CommandButton1_Click()
stop_flag = False
TextBox1.Text = 0
TextBox2.Text = 0
TextBox3.Text = 0
TextBox4.Text = 0
TextBox5.Text = 0
CommandButton2.Enabled = True
Dim a, b, c, d, e As Integer, arr1, arr2, arr
arr1 = Array(1,2,3)
arr2 = Array(4,5,6)
arr = Split(Join(arr1, “,”) & “,” & Join(arr2, “,”), “,”)'抽奖人数多的时候用
Do
a = Int(Rnd() * 153)'rnd是[0,1)
b = Int(Rnd() * 153)
c = Int(Rnd() * 153)
d = Int(Rnd() * 153)
e = Int(Rnd() * 153)
TextBox1.Text = arr(a)
TextBox2.Text = arr(b)
TextBox3.Text = arr©
TextBox4.Text = arr(d)
TextBox5.Text = arr(e)
DoEvents’将事务交给计算机,可以进行其他操作
If stop_flag = True Then
Exit Do
End If
Loop
End Sub
Private Sub CommandButton2_Click()
CommandButton2.Enabled = False
stop_flag = True
End Sub