一是会出现重复。
二是会发生”下标越界“。如在这里:
Private Sub Timer1_Timer()
Static i As Integer '定义I为变量
If i >200 Then i = 1当I=200时
i = i + 1会出现I=201
Label1 = a(i)下标越界
End Sub
建议多试试,修改好再考虑下一步事情。好吗?
原理:随机函数 加 号码池吧
代码大致如下:
Private Sub Command1_Click()
Dim NumArr(77) As Integer, result As String
Dim n As Integer '要摇号的个数
For i = 0 To 77
NumArr(i) = i + 1
Next i
n = 5
result = "本次摇号结果:"
Dim tmp
Do While n >0
Randomize
tmp = Int(Rnd * (73 + n))
If NumArr(tmp) <>0 Then
result = result &" " &NumArr(tmp)
NumArr(tmp) = 0
n = n - 1
End If
Loop
Debug.Print result
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)