Board index » Visual Studio » MultiColor Calculations

MultiColor Calculations

Visual Studio315
I need to make a program that uses ten basic colors (eg. red,green,blue) in combinations. I need each color to make a combination as a pair and triple with other colors. For example: red|green, red|blue, red|yellow, green|blue, and so on, but you can't use green|red because we already use red|green. Get it?, then i have to make multiples of threes as well red|green|blue etc..

I have no idea where to begin or how I should set this up, I sure in an array of some sort or recursive callbacks, any suggestions would be appreciated

Thanks.


-
 

Re:MultiColor Calculations

something like



dim colors() as String

dim duoColorCollection as Collection



dim i as integer

dim j as integer



for i = 0 to colors.lenght - 2

for j=i +1 to colors.lenght - 1

duoColorCollection.add(colors(i) + "-" + colors(j))

next j

next i



duocollorscollection will contain all "mixed" colors but no "inverse equals"



i hope what i wrote is right, did it without testing ;-)

but the system can be something like this





hope this helps



dominique





"OptikConnex" <anonymous@discussions.microsoft.com>wrote in message

Quote
I need to make a program that uses ten basic colors (eg. red,green,blue)

in combinations. I need each color to make a combination as a pair and

triple with other colors. For example: red|green, red|blue, red|yellow,

green|blue, and so on, but you can't use green|red because we already use

red|green. Get it?, then i have to make multiples of threes as well

red|green|blue etc...

Quote
I have no idea where to begin or how I should set this up, I sure in an

array of some sort or recursive callbacks, any suggestions would be

appreciated.

Quote
Thanks.





-

Re:MultiColor Calculations

I don't quite see what you are doing in your posted code. How would I display the colors side by side then. And what are you assigning colors to

dim colors() as Strin

dim duoColorCollection as Collectio



dim i as intege

dim j as intege



for i = 0 to colors.lenght -

for j=i +1 to colors.lenght -

duoColorCollection.add(colors(i) + "-" + colors(j)

next

next



-

Re:MultiColor Calculations

Scratch that last comment i see what you are doing. Just needed the caffeine to get me going. But now I get an erro

at this line of code: duoColorCollection.Add(colors(i) + "-" + colors(j)) what do i need to do next



Dim colors(4) As Strin

Dim duoColorCollection As Collectio



Dim i As Intege

Dim j As Intege

colors(1) = "Red

colors(2) = "Green

colors(3) = "Blue

colors(4) = "Purple



For i = 0 To colors.Length -

For j = i + 1 To colors.Length -

duoColorCollection.Add(colors(i) + "-" + colors(j)

Next

Next



-

Re:MultiColor Calculations

OK I figured most of it out now, but how do I display the results. Here is the code



Dim colors(4) As Strin

Dim duoColorCollection As New Collectio



Dim i As Intege

Dim j As Intege

colors(1) = "Red

colors(2) = "Green

colors(3) = "Blue

colors(4) = "Purple



For i = 0 To colors.Length -

For j = i + 1 To colors.Length -

duoColorCollection.Add(colors(i) + "-" + colors(j)

Next

Next

Where do I display my results eg red-gree

Im an idiot, I know but things aren't clicking today.

-

Re:MultiColor Calculations

your duocolorcollection is a collection containing strings ("Red-Green",

"Red-Blue", ...)



so just do something like



dim oneColor as string

for each oneColor in duoColorCollection

debug.writeline(oneColor)

next





PS:

I even didn't know the collection object realy exists, i was pointing to

some kind of collection object (arraylist,...)

java background you know ;-)





"OptikConnex" <anonymous@discussions.microsoft.com>wrote in message

Quote
OK I figured most of it out now, but how do I display the results. Here is

the code.



Dim colors(4) As String

Dim duoColorCollection As New Collection



Dim i As Integer

Dim j As Integer

colors(1) = "Red"

colors(2) = "Green"

colors(3) = "Blue"

colors(4) = "Purple"



For i = 0 To colors.Length - 2

For j = i + 1 To colors.Length - 1

duoColorCollection.Add(colors(i) + "-" + colors(j))

Next j

Next i

Where do I display my results eg red-green

Im an idiot, I know but things aren't clicking today.





-