|
-
Jul 1st, 2001, 12:56 AM
#1
number picker
hello all....
I need some code that will take 7 - 49 numbers (for the lotto)
that the user chooses and spit out all the different 3 number combinations and then all the different 6 number combinations
ie.
1 2 3 4 5 6 7
would be..
123
124
125
126
127
134
135
136
137 and so on
and then the would need to be combined into
123 456
123 457
the more numbers the user chooses the longer the list would be obviosly, any way
any one know the best way to do this?
thanks in advance
jon
-
Jul 1st, 2001, 01:02 AM
#2
Fanatic Member
Try this
Private Sub Form_Load()
Dim thenum as Integer
Dim therot as integer
Randomize
thenum = "200" 'This will generate numbers from 1 - 200
therot = Int((thenum*Rnd)+1)
Msgbox therot
if therot = "123" then
msgbox "You've won the Lottery! here's 1 million for prog_tom..."
else
msgbox "Sorry you lost, but still 1 million for prog_tom!"
end if
end sub

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 01:17 AM
#3
but "randomize" doesnt put them into any order, it just randomizes all the numbers.
I need it to list all the different combinations (ignoring duplicates)
basicly the program is supposed to spit out all the different combinations of up to 49 numbers ( for the pick 6 lotto ) so if the user chooses 8 different numbers the program will give you all the different combinations of those 8 numbers ( in a a six number sequence) minus the duplicates. so the output would look like:
Here are the numbers:
123456
123457
123458
There are 3345 different combinations
-
Jul 1st, 2001, 01:18 AM
#4
Fanatic Member
Whole thing
if you want to DRAW for the Lottery until it's drawed to "123" try this code, requires two LABELS, a "l" and a "o"
Private Sub co_Click()
Dim thenum As Integer
Dim therot As Integer
Randomize
thenum = "200" 'This will generate numbers from 1 - 200
therot = Int((thenum * Rnd) + 1)
l.Caption = therot
If therot = "123" Then
o = "You've won the Lottery! here's 1 million for prog_tom..."
Else
o = "Sorry you lost, but still 1 million for prog_tom!"
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
co_Click
Else
End If
End Sub
Private Sub Form_Load()
Me.Move -Me.Width + Screen.Width, -Me.Height + Screen.Height + (-400)
Do Until l.Caption = "123"
co_Click
Open "c:\ot.txt" For Append As #2
Print #2, "============"
Print #2, l.Caption
Print #2, o.Caption
Print #2, "==============="
Close #2
Loop
Shell "notepad.exe " & "c:\ot.txt"
End Sub
Also saves a LOG file to c:\ot.txt
You'd better thank me, do you chat on Yahoo Pager? mine id is prog_tom

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 01:26 AM
#5
Fanatic Member
I'm lost too. Is this a lotto number picker?
Chris
-
Jul 1st, 2001, 01:38 AM
#6
lol i know i didnt really understand it at first either ( its for a friend of mine)
ok here we go
the lotto 6/49 ... you can pick any number between 1 and 49
normally you would pick 6 numbers
he wants to pick more than 6 and play them all
ie. 8 numbers
so he wants to know all the different combinations of those 8 numbers arranged in groups of 6
so if he picked the numbers 1 2 3 4 5 6 7 8
then the program would spit out all the different combinations
123456
123457
123458
134567
135678
145678
14...ect. ect.
know what i mean?
jon
-
Jul 1st, 2001, 01:43 AM
#7
Fanatic Member
Still lost...
It matters what order the numbers are in? That's what's throwing me. It's not just a random selection procedure?
Chris
-
Jul 1st, 2001, 02:01 AM
#8
Fanatic Member
If you wait
if you wait like 10 hours, I'll get you the Code... Meet me on Yahoo Pager, prog_tom is my id.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 02:02 AM
#9
I dont think it matters what order the combinations of 6 are in as long as all the possible combinations are listed and there are no doubles.
I think he wants to have it so he can pick, lets say 8 numbers ( to increase his odds) and play all combinations of those numbers, so the program will spit out the combinations and hee will go buy all the tickets that would cover those 8 numbers ( thats why there cant be any duplicates)
-
Jul 1st, 2001, 02:28 AM
#10
Fanatic Member
Done:)
check it out
Private Sub co_Click()
Dim thenum As Long
Dim therot As Long
Randomize
thenum = "999999" 'This will generate numbers from 1 - 999999
therot = Int((thenum * Rnd) + 1)
l.Caption = therot
If therot > "100000" And therot = "475817" Then
o = "You've won the Lottery! here's 1 million for prog_tom..."
ElseIf therot < "100000" Then
o = "Not ENOUGH NUMBERS"
Else
o = "Sorry you lost, but still 1 million for prog_tom!"
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
co_Click
Else
End If
End Sub
Private Sub Form_Load()
Me.Move -Me.Width + Screen.Width, -Me.Height + Screen.Height + (-400)
Do Until l.Caption = "475817"
co_Click
Open "c:\ot.txt" For Append As #2
Print #2, "============"
Print #2, l.Caption
Print #2, o.Caption
Print #2, "==============="
Close #2
Loop
Shell "notepad.exe " & "c:\ot.txt", vbNormalFocus
Kill ("c:\ot.txt")
End Sub
It's gonna generate a .txt that's around 2MB!!! Takes a while to generate the lucky number, if the number doesn't have 6 digits it's gonna be wrote on the file saying "NOT ENOUGH NUMBERS"

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 02:37 AM
#11
Registered User
Here is the code for the permutations, note that it prints to the debug window and not all values will be posted there as it maxes out at around 255 lines of text (or something like that). It get around this fill an array instead of printing to the debug window. It is easier to follow the logic without this extra overhead.
VB Code:
Option Explicit
Private Sub Command1_Click()
Call Shuffle("1,2,3,4,5,6,7,8")
End Sub
Sub Shuffle(ByVal s As String)
Dim a As Variant
Dim b As Long
Dim c As String
Dim i As Long
Dim j As Long
a = Split(s, ",")
For i = 0 To 7
b = i
For j = 0 To 5
If b > 7 Then b = 0
c = c & a(b)
b = b + 1
Next j
Call Permutations(c)
c = ""
Next i
End Sub
Sub Permutations(s As String, Optional sLeading As String)
Dim i As Long
For i = 1 To Len(s)
If Len(s) > 2 Then
Permutations Right$(s, Len(s) - 1), sLeading & Left$(s, 1)
Else
Debug.Print sLeading & s
End If
s = Right$(s, Len(s) - 1) & Left$(s, 1)
Next
End Sub
-
Jul 1st, 2001, 02:37 AM
#12
Prog_tom
i dont think that will work ???
you can only pick the numbers 1 to 49 in the lottery
-
Jul 1st, 2001, 02:41 AM
#13
Fanatic Member
OK I Fixed the NON 6digit
I've fixed the Non 6 Digit problem...
Private Sub co_Click()
Dim thenum As Long
Dim therot As Long
Randomize
thenum = "999999" 'This will generate numbers from 1 - 999999
therot = Int((thenum * Rnd) + 1)
l.Caption = therot
If therot > "100000" And therot = "889499" Then
o = "You've won the Lottery! here's 1 million for prog_tom..."
Open "c:\ot.txt" For Append As #2
Print #2, "============"
Print #2, l.Caption
Print #2, o.Caption
Print #2, "==============="
Close #2
ElseIf therot < "1000" Then
o = "Not ENOUGH NUMBERS"
Else
o = "Sorry you lost, but still 1 million for prog_tom!"
Open "c:\ot.txt" For Append As #2
Print #2, "============"
Print #2, l.Caption
Print #2, o.Caption
Print #2, "==============="
Close #2
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
co_Click
Else
End If
End Sub
Private Sub Form_Load()
Me.Move -Me.Width + Screen.Width, -Me.Height + Screen.Height + (-400)
Do Until l.Caption = "889499"
co_Click
Loop
Shell "notepad.exe " & "c:\ot.txt", vbNormalFocus
Kill ("c:\ot.txt")
End Sub
I waited so long to Generate it around 5 minutes!!!

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 02:43 AM
#14
as well the user might want to pick 7 or 9 numbers so the program needs to be able to handle using anywhere from 7 to 49 different numbers ( although if he picked 49 numbers then there would be like 180 million different combinations and if he had 180 million dollars i dont think hed be playing the lottery !!!!
-
Jul 1st, 2001, 02:48 AM
#15
Fanatic Member
No problem
, no problem man. Give me 1 hour, hey get Yahoo Pager!!!!!!
http://pager.yahoo.com
I'll give you the Lottery game...
My Yahoo ID is prog_tom

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 1st, 2001, 03:13 AM
#16
Fanatic Member
Done my man:)

You'd better thank me...
Private Sub co_Click()
Dim thenum As Integer
Dim s As Integer, d As Integer, f As Integer, g As Integer, h As Integer, j As Integer, k As Integer, l As Integer
Randomize
Dim thewhole As Long
Dim thewhole_r As String
Dim therot As Integer
Randomize
thenum = "49" 'This will generate numbers from 1 - 49
s = Int((thenum * Rnd) + 1)
d = Int((thenum * Rnd) + 1)
f = Int((thenum * Rnd) + 1)
g = Int((thenum * Rnd) + 1)
h = Int((thenum * Rnd) + 1)
j = Int((thenum * Rnd) + 1)
k = Int((thenum * Rnd) + 1)
m = Int((thenum * Rnd) + 1)
therot = Int((thenum * Rnd) + 1)
thewhole = therot + s + d + f + g + h + j + k + m
thewhole_r = therot & " " & s & " " & d & " " & f & " " & g & " " & h & " " & j & " " & k & " " & m
we.Caption = thewhole_r
If thewhole_r = "45 " & "23 " & "3 " & "5 " & "8 " & "9 " & "1 " & "42 " & "14 " Or thewhole = "150" Then
o = "You've won the Lottery! here's 1 million for prog_tom..."
Else
o = "Sorry you lost, but still 1 million for prog_tom!"
End If
End Sub
Private Sub Form_Load()
Me.Move -Me.Width + Screen.Width, -Me.Height + Screen.Height + (-400)
co_Click
End Sub
And the best of all, I'm the Youngest!!! I'm 12...
In this case, I've added 9 Numbers, each is from 1 to 49. Now if
the user got 45 23 3 5 8 9 1 42 14, or any number adds up to 150, then he will win!!!
Last edited by prog_tom; Jul 1st, 2001 at 03:16 AM.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
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
|