Generates a random number that does not repeat

Source: Internet
Author: User
Tags integer
Repeat this article is absolutely accidental chance, the year before last, and so on a new day's day, and his wife Street stroll, suddenly remembered to buy a welfare lottery ticket, the result
Fart is not in the first day of spring, wrote a forecast lottery winning program, which is a key algorithm is how to generate a repeat of the number,
Everyone after reading this program, if the jackpot, do not forget tofu AH:
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 ((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
Oh, after a few days, I put this program into components, put it on my site everyone to play together, hehe!
/*
Tofu production is a boutique
Http://www.asp888.net Tofu Technology Station
If reproduced please retain the full copyright information
*/



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.