all the possible sequences for numbers 1,2,3,4,5,6,7,8,9,10 in groups of 5.

so I need to write a VB6 program that will generate all the possible sequences for numbers 1-10 in groups of 5.  
below is a starting sequence but not sure how to do it in a program.

1 2 3 4 5 61 2 3 4 5 10
1 2 3 4 6 7
1 2 3 4 5 7
1 2 3 4 5 8
1 2 3 4 5 9

1 2 3 4 6 8
1 2 3 4 6 9
1 2 3 4 6 10
1 2 3 4 7 8
1 2 3 4 7 9
1 2 3 4 7 10

etc
rjefAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
If you want combinations where for example 12345 would be considered the same as 13245 then you'd get about 240 results. If you want permutations where for example 12345 would be not considered the same as 13245 then you'd get about 30,000 results. Which do you want?
0
rjefAuthor Commented:
where 12345 is the same as 13245.  (combinations)
would just make 5 loops from 1 to 10 and check for duplicates and repeats or is there a function?
0
Martin LissOlder than dirtCommented:
The following code requires a form with a listbox named List1 and a command button named Command1.
Private Sub Command1_Click()

Dim varArray() As Variant
varArray = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

List1.Clear
GenerateCominationOf5 varArray

End Sub

Private Sub GenerateCominationOf5(varArray() As Variant)

On Error GoTo GenerateCominationOf5Error

Dim intCount1 As Integer
Dim intCount2 As Integer
Dim intCount3 As Integer
Dim intCount4 As Integer
Dim intCount5 As Integer
Dim intUBound As Integer
Dim injtLBound As Integer

intUBound = UBound(varArray)
injtLBound = LBound(varArray)

For intCount1 = injtLBound To intUBound
  For intCount2 = intCount1 + 1 To intUBound
    For intCount3 = intCount2 + 1 To intUBound
      For intCount4 = intCount3 + 1 To intUBound
        For intCount5 = intCount4 + 1 To intUBound
            List1.AddItem varArray(intCount1) & "," & varArray(intCount2) & "," & _
                          varArray(intCount3) & "," & varArray(intCount4) & "," & _
                          varArray(intCount5)
        Next intCount5
      Next intCount4
    Next intCount3
  Next intCount2
Next intCount1

MsgBox "Generated " & List1.ListCount & " combinations"
Exit Sub
GenerateCominationOf5Error:

MsgBox "GenerateCominationOf5 " & Err.Number & ":" & Err.Description

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rjefAuthor Commented:
thanks
0
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2016
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.