做个抽奖程序有个问题 怎么让数字随即不重复出现
发布网友
发布时间:2022-05-16 09:21
我来回答
共1个回答
热心网友
时间:2023-10-18 04:21
自己修改,看看有没有重复的
Private Sub Command1_Click()
Dim dic, n, a
Set dic = CreateObject("scripting.dictionary")
Do While True
Randomize
a = Int(120 * Rnd) + 1
If Not dic.Exists(a) Then
dic.Add a, ""
n = n + 1
End If
If n = 120 Then Exit Do
Loop
a = dic.keys
Text1 = Join(a, ",")
End Sub