/* 豆腐制作 都是精品 http://www.asp888.net 豆腐技術(shù)站 如轉(zhuǎn)載 請保留完整版權(quán)信息 */ 寫這個文章絕對是偶然的偶然的機會,前年等一回的 元旦節(jié),和 老婆上街 溜達,猛然想起買上一張福利彩票,結(jié)果 屁都沒有中上,開春第一天,就寫了個預測彩票中獎的程序,這其中的一個很關(guān)鍵的算法就是如何生成一個不重復的隨即數(shù) 字, 大家看完這個程序以后如果中獎,千萬不要忘記豆腐了呀:) Sub CalCaPiao() Dim strCaiPiaoNoArr() As String Dim strSQL As String Dim strCaiPiaoNo As String strCaiPiaoNo = "01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33" Dim StrTempArr(7) As String Dim strZhongJiangArr(7) As String strCaiPiaoNoArr = Split(strCaiPiaoNo, ",") Dim intRand As Integer Dim i As Integer Dim j As Integer i = 0 Dim find As Boolean Do While True find = False Randomize intRand = Int((33 * Rnd) + 1) For j = 0 To i - 1 If StrTempArr(j) = CStr(intRand) Then find = True End If Next If Not find Then StrTempArr(j) = CStr(intRand) strZhongJiangArr(i) = CStr(intRand) 'Text1(i) = strZhongJiangArr(i) i = i + 1 If i = 7 Then Exit Do End If End If Loop End Sub 呵呵,過幾天,我把這個程序搞成組件,放到我的站點上 大家一起來玩玩,呵呵!
.
|