array algorithm

hi,

we have an array called arr_combination(3,0) we need to place integers in the X axis and the sum total should be 30.

there's two limitations, a minimum and a maximum number allowed to be used.

i.e.

min=6
max=11
place all possible in the array arr_combination(3,0).

11,7,6,6=30
11,6,7,6=30
6,7,6,11=30
7,6,6,11=30
6,11,7,6=30
8,9,7,6=30
9,8,6,7=30
.....


Thanks.




RyanBankAsked:
Who is Participating?
 
fadlounCommented:
Hello
place a listbox on the form

Private Sub Command1_Click()
Dim Min As Long
Dim Max As Long
Dim Goal As Long

Min = 2
Max = 11
Goal = 30
For I = Min To Max
    For I2 = Min To Max
        For I3 = Min To Max
            For I4 = Min To Max
                If I + I2 + I3 + I4 = Goal Then List1.AddItem I & "," & I2 & "," & I3 & "," & I4
            Next
        Next
    Next
Next

End Sub


this will list all the possiblities,then you can bind I,I2,I3,I4 to your array

regards
0
 
fadlounCommented:
Min = 6

I change it to 2 for testing ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.