robtyketto
Member
- Joined
- Jul 23, 2009
- Messages
- 23
- Programming Experience
- Beginner
Greetings,
I shied away from using structures (see previous post) and thought about using collections or control away to track related picture boxes.
I went with control arrays (see code below).
After some reasearch I believe control arrays are difficult to use and the code below will never work.
I have another version of the code that loops around using for each control and then checking the control type and then where name like 'xxx*"
How can I collectively store all the picturebox controls in one group and reference them by an index value?
Thanks
Rob
I shied away from using structures (see previous post) and thought about using collections or control away to track related picture boxes.
I went with control arrays (see code below).
After some reasearch I believe control arrays are difficult to use and the code below will never work.
I have another version of the code that loops around using for each control and then checking the control type and then where name like 'xxx*"
How can I collectively store all the picturebox controls in one group and reference them by an index value?
VB.NET:
Dim dice() As PictureBox = {picDice1, picDice2, picDice3, picDice4, picDice5, picDice6}
'Declare variable to hold index of picture in imagelist, rand for a random num
'and ctrlvar as control to enable looping through all controls
Dim intPic As Integer
Dim rand As New Random
Dim index As Integer = 0
'Assign random dice head/value to the six dice
For Each die As PictureBox In dice
' Pick a random number between 0 and the number of images in our imagelist control
intPic = rand.Next(0, ImageList1.Images.Count)
'die(0).Image = ImageList1.Images(intPic)
dice(0).Image = ImageList1.Images(intPic)
index += 1
Next
Thanks
Rob