andrew93
08-20-2006, 02:36 AM
Hi
I'm working on a VB6 project and am seeking an elegant solution to some messy coding, if possible. My form is displaying 36 pairs of outcomes based on various things, including 2 dice results. I am showing the results in a 6x6 grid made up of 36 text boxes labelled "Outcome1" through to "Outcome36". The 36 pairs of results are stored in arrays, ie. Dice1(35) & Dice2(35). Is it possible to use a loop to select each 'Outcome' text box? At the moment my code looks like this :
Outcome1.Caption = Dice1(0) & ", " & Dice2(0)
Outcome2.Caption = Dice1(1) & ", " & Dice2(1)
Outcome3.Caption = Dice1(2) & ", " & Dice2(2)
'....etc etc etc
Is there a smarter way of doing this with a loop? If so, how do I get the code to select the correct outcome box based on a loop counter?
Thanks in advance
Andrew
I'm working on a VB6 project and am seeking an elegant solution to some messy coding, if possible. My form is displaying 36 pairs of outcomes based on various things, including 2 dice results. I am showing the results in a 6x6 grid made up of 36 text boxes labelled "Outcome1" through to "Outcome36". The 36 pairs of results are stored in arrays, ie. Dice1(35) & Dice2(35). Is it possible to use a loop to select each 'Outcome' text box? At the moment my code looks like this :
Outcome1.Caption = Dice1(0) & ", " & Dice2(0)
Outcome2.Caption = Dice1(1) & ", " & Dice2(1)
Outcome3.Caption = Dice1(2) & ", " & Dice2(2)
'....etc etc etc
Is there a smarter way of doing this with a loop? If so, how do I get the code to select the correct outcome box based on a loop counter?
Thanks in advance
Andrew