推 shiningstar:謝謝 :) 原來有這麼簡單的寫法 thx~~ 61.228.86.153 05/25
雖然不是直接回你的問題
你應該是要做自動選號之類的?
不過不用這麼麻煩啊...可以先產生不重複的數字
然後拿來勾checkbox就不會有問題啦
如下
存數字的陣列
Dim LotteryNum(6) As Integer
產生選號的程序(結果未排序)
Sub LotteryGenerator()
Dim i As Integer, j As Integer, k As Integer, isSame As Boolean
Randomize
Do Until i > 6
k = Int(Rnd * 49 + 1)
For j = 0 To i - 1
If k = LotteryNum(j) Then isSame = True
Next j
If Not isSame Then
LotteryNum(i) = k
i = i + 1
End If
isSame = False
Loop
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.80.249