• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

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.




0
RyanBank
Asked:
RyanBank
  • 2
1 Solution
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now