Combinations

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaakinye
    New Member
    • Jan 2007
    • 8

    Combinations

    I need code in VB for combinations
    For example k of n numbers (6 of 45) for lottary
  • bplacker
    New Member
    • Sep 2006
    • 121

    #2
    after one google search i found this, you'll have to download the source code and change it to .net, but it should help. You can't expect someone to do ALL the work for you!

    http://www.freevbcode. com/ShowCode.asp?ID =3033

    Comment

    • Gilfindore
      New Member
      • Jan 2007
      • 4

      #3
      Hello jaakinye

      This code should do it.

      Code:
      int1 = 1 + Rnd() * 44
      int2 = 1 + Rnd() * 44
      [INDENT]Do While int1 = int2
      int2 = 1 + Rnd() * 44
      Loop[/INDENT]
      int3 = 1 + Rnd() * 44[INDENT]Do While int1 = int3 Or int2 = int3
      int3 = 1 + Rnd() * 44
      Loop[/INDENT]
      int4 = 1 + Rnd() * 44[INDENT]Do While int1 = int4 Or int2 = int4 Or int3 = int4
      int4 = 1 + Rnd() * 44
      Loop[/INDENT]
      int5 = 1 + Rnd() * 44[INDENT]Do While int1 = int5 Or int2 = int5 Or int3 = int5 Or int4 = int5
      int5 = 1 + Rnd() * 44
      Loop[/INDENT]
      int6 = 1 + Rnd() * 44[INDENT]Do While int1 = int6 Or int2 = int6 Or int3 = int6 Or int4 = int6 Or int5 = int6
      int6 = 1 + Rnd() * 44
      Loop[/INDENT]

      Comment

      Working...