Getting list number from variable
Code:
For j = 1 To 12
For i = 1 To 31
Randomize
x = Int(Rnd * 13 + 1)
winner(j, i) = x
Listj.AddItem winner(j, i)
Next i
Next j
How can i accomplish adding the numbers to different Listboxes? The number of list depends on the counter of the outer for cycle (So i want to put 31 random numbers to different ListBoxes, e.g. List1, List2, .. List12)
Edit: Actually if there's a simple way to show these data in a table, that would do it too.
Re: Getting list number from variable
Please explain the rules of the game.
BTW, Randomize should only be called once
at the beginning of program run, not in a loop.
Re: Getting list number from variable
Code:
Me.Controls("List" & j).AddItem winner(j, i)
:wave:
Re: Getting list number from variable
Here is a loop that will add odd numbers to listbox1 and even numbers to listbox2:
vb Code:
For j = 1 To 12
For i = 1 To 31
Randomize
x = Int(Rnd * 13 + 1)
winner(j, i) = x
If j / 2 = int(j / 2) Then
ListjEven.AddItem winner(j, i)
Else
ListjOdd.AddItem winner(j, i)
EndIf
Next i
Next j
Re: Getting list number from variable
Quote:
Originally Posted by
akhileshbc
Code:
Me.Controls("List" & j).AddItem winner(j, i)
Thanks, this one has really worked! :)