Results 1 to 16 of 16

Thread: number picker

  1. #1
    Jonis
    Guest

    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

  2. #2
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Unhappy 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

  3. #3
    Jonis
    Guest
    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

  4. #4
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Talking 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

  5. #5
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    I'm lost too. Is this a lotto number picker?


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  6. #6
    Jonis
    Guest
    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

  7. #7
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    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
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  8. #8
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Wink 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

  9. #9
    Jonis
    Guest
    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)

  10. #10
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    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

  11. #11
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    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:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  Call Shuffle("1,2,3,4,5,6,7,8")
    5. End Sub
    6.  
    7. Sub Shuffle(ByVal s As String)
    8. Dim a       As Variant
    9. Dim b       As Long
    10. Dim c       As String
    11. Dim i       As Long
    12. Dim j       As Long
    13.  
    14. a = Split(s, ",")
    15. For i = 0 To 7
    16.     b = i
    17.     For j = 0 To 5
    18.         If b > 7 Then b = 0
    19.         c = c & a(b)
    20.         b = b + 1
    21.     Next j
    22.     Call Permutations(c)
    23.     c = ""
    24. Next i
    25.  
    26. End Sub
    27.  
    28.  
    29. Sub Permutations(s As String, Optional sLeading As String)
    30.  Dim i       As Long
    31.  
    32.  For i = 1 To Len(s)
    33.     If Len(s) > 2 Then
    34.         Permutations Right$(s, Len(s) - 1), sLeading & Left$(s, 1)
    35.     Else
    36.         Debug.Print sLeading & s
    37.     End If
    38.     s = Right$(s, Len(s) - 1) & Left$(s, 1)
    39.  Next
    40. End Sub

  12. #12
    Jonis
    Guest
    Prog_tom

    i dont think that will work ???

    you can only pick the numbers 1 to 49 in the lottery

  13. #13
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Smile 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

  14. #14
    Jonis
    Guest
    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 !!!!

  15. #15
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Cool 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

  16. #16
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Smile 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
  •  



Click Here to Expand Forum to Full Width