|
-
Apr 14th, 2002, 12:39 PM
#1
Saving lottery numbers in a database, in VB.4.0
How do I create a database program in VB4.o to hold the numbers generated as random numbers to a database, with the day and year. And then be able to retrieve them at anytime
Also how can I make this ainto a option for the user to pick as many sets of numbers as the user wants eg. win 4 99 sets of four random numbers without repeating the numbers already chosen?
This is the code written so far
Private Sub Command1_Click()
Dim Lottery(6) As Integer ' array to hold final selected numbers
Dim nLucky As Integer ' variable to hold each random selection
Dim nCount As Integer ' counter for number of selections made
Dim nCheck As Integer ' counter for check on previous selections
For nCount = 1 To 6 ' choose 6 numbers
Start: ' lets go (again)
Randomize ' random-seed the random generator
nLucky = Int((59 * Rnd) + 1) ' pick random number from 1 to 49
For nCheck = 1 To 6
If nLucky = Lottery(nCheck) Then ' if seleced number has already been picked...
GoTo Start ' go back and pick another number.
End If
Next nCheck
Lottery(nCount) = nLucky ' store selection in array
Label1(nCount - 1) = Lottery(nCount) ' apply selection to labels (-1 for 0 to 5)
Next nCount
Thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|