为什么小弟我做的这段抽奖程序会出现cpu 100%的假死机呢

为什么我做的这段抽奖程序会出现cpu 100%的假死机呢?
VB code

Private Sub Timer1_Timer()
  Label2.Alignment = 2
  Label3.Alignment = 2
  Label4.Alignment = 2
  
If ten_flag = False Then
  Do
    num = Int(660 * Rnd + 1)
    num4 = num
    num1 = num4 Mod 10  '个位
    num4 = Int(num4 / 10)
    num2 = num4 Mod 10  '十位
    num4 = Int(num4 / 10)
    num3 = num4 Mod 10  '百位
  Loop While tempnum(num) = 1
    tempnum(num) = 1
  Label4.Caption = num1
  Label3.Caption = num2
  Label2.Caption = num3
  str_temp = Label2.Caption + Label3.Caption + Label4.Caption
  
Else
    str_temp = ""
    For ten_i = 1 To 10
      Do
        num = Int(660 * Rnd + 1)
        num4 = num
        num1 = num4 Mod 10  '个位
        num4 = Int(num4 / 10)
        num2 = num4 Mod 10  '十位
        num4 = Int(num4 / 10)
        num3 = num4 Mod 10  '百位
      Loop While tempnum(num) = 1
        tempnum(num) = 1
        Label4.Caption = num1
        Label3.Caption = num2
        Label2.Caption = num3
        str_temp = str_temp + Label2.Caption + Label3.Caption + Label4.Caption + " " 
    Next ten_i
End If



后半段是连续抽出10名。
求帮助!

------解决方案--------------------
发完,发现代码那么难看啊……还不让编辑!!!再发一次试试:

  程序俺写好了。不是俺好心,真是因为俺是新手,也想练练手!!!哈哈。这个程序当前不通用。改成通用的话哪,似乎也不是很难。算啦,就这样了。
  
  另外,俺认为,14楼的说法,并不实用。俺还真的是用电脑,把真实要抽的数字给随机显示了,不是“弄个假样子”。为什么这样呢?设想个情形:
  年终啦,要发奖,领导发给员工的号,是1至660。结果,你百位上老是在闪动“7、8、9”这些个数字,实在不怎么好看……呵呵。
  还有啊,就是,
  俺的这个程序啊,稍微一改造(对应个数据库什么的),就成了“课堂随机提问”之类,到时候,闪动的,不是数字,而是名字!!!名字呀。

  呵呵,不啰嗦了,代码如下:

界面:

label1,label2,text1,command1,timer1

代码:

Dim temp(1 To 10) As Integer '抽10次好验证,您再另外改吧。呵呵。俺慵懒中……
Dim tempNum As Integer
Dim theOrder As Integer

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 10
theOrder = 1
Label1.Caption = "您马上要抽取的是顺序号是:"
Label2.Caption = "1"
Command1.Caption = "抽奖啦!"
For i = 1 To 10 '只抽10次
temp(i) = i
Next i
End Sub
'这个按钮要按两次,第一次,开抽,激活Timer;第二次,定奖,关闭Timer
Private Sub Command1_Click()
Dim a As Integer
If theOrder > 10 Then '若超过10次
Text1.Text = "抽完啦!"
Exit Sub
End If
  
If Timer1.Enabled = False Then '若未抽状态,则开抽,进入timer循环体
Timer1.Enabled = True
Else '否则,停止timer计时器,得到结果,并开始交换处理。
Timer1.Enabled = False
a = temp(theOrder)
Debug.Print tempNum
temp(theOrder) = temp(tempNum)
temp(tempNum) = a
theOrder = theOrder + 1
Label2.Caption = Str(theOrder)

End If

  
End Sub

Private Sub Timer1_Timer()
Randomize
tempNum = theOrder + Int(Rnd() * (10 + 1 - theOrder)) '乘数有讲究,上帖俺少了括号。
Text1.Text = temp(tempNum)
End Sub


此程序俺已成功实验过。俺也新手,也希望得到楼主以后的照顾。谢谢。

------解决方案--------------------
这是10个一起抓的代码。
需要一个Command1按钮、一个Timer1控件、一个Text1文本框。
Text1.MultiLine需要设置为True。

VB code

Option Explicit

Private priNumList() As Long
Private priOutList() As String

Private Sub Form_Load()
  '需要设置Text1.MultiLine = True
  Timer1.Enabled = False
  Dim tIndex As Long
  Dim tNumCount As Long
  Dim tOutCount As Long
  tNumCount = 660 '可以把这个数字设置成10来测试它是否准确。
  tOutCount = 10
  ReDim priNumList(tNumCount - 1)
  ReDim priOutList(tOutCount - 1)
  
  For tIndex = 0 To tNumCount - 1
    priNumList(tIndex) = tIndex
  Next
  
  Command1.Caption = "开始"
  Timer1.Interval = 10
End Sub

Private Sub Command1_Click()
  '开始
  Timer1.Enabled = Not Timer1.Enabled
  Command1.Caption = Split("开始,停止", ",")(Timer1.Enabled And 1)
End Sub

Private Sub ListSwap(ByRef pList() As Long, ByRef pIndex As Long)
  '将pIndex指定的元素与后面的随机元素交换。
  Dim tDesIndex As Long
  tDesIndex = Int(Rnd * (UBound(pList()) - pIndex)) + pIndex
  ValueSwap pList(pIndex), pList(tDesIndex)
End Sub

Private Sub ValueSwap(ByRef pA As Long, ByRef pB As Long)
  '交换两个Long的值。
  Dim tT As Long
  tT = pA: pA = pB: pB = tT
End Sub

Private Sub Timer1_Timer()
  Dim tIndex As Long
  For tIndex = 0 To 9
    ListSwap priNumList(), tIndex
    priOutList(tIndex) = Format(tIndex + 1, "00") & " " & Format(priNumList(tIndex), "000")
  Next
  Text1.Text = Join(priOutList, vbCrLf)
End Sub