Computer Science Canada

Need help creating random values that can't be repeated

Author:  blizzard4800 [ Sun Jun 05, 2011 10:44 pm ]
Post subject:  Need help creating random values that can't be repeated

I need help assigning random values to different to buttons which are supposed to have values.
If you still don't understand it is for a deal or no deal project where the cases( which are buttons) have different values.

Author:  Nick [ Sun Jun 05, 2011 10:48 pm ]
Post subject:  RE:Need help creating random values that can\'t be repeated

do you have your buttons in a control array?

if so, in your form.load event just have a for each loop and assign a value to each button's tag property.

Author:  blizzard4800 [ Sun Jun 05, 2011 10:50 pm ]
Post subject:  RE:Need help creating random values that can\'t be repeated

no i dont have them in an array

Author:  Raknarg [ Sun Jun 05, 2011 10:59 pm ]
Post subject:  RE:Need help creating random values that can\'t be repeated

You should. There's two options here. The easier but more tedious way is to create 51 buttons, and assign an array to each button. Ex:

Dim tiles(51) As Button
tiles(1) = Button1
tiles(2) = Button2
etc...

Or you can create you own buttons. That's possible, it can just be a bit annoying to do. Ex:

dim tiles(51) As Button
For i = 1 to 51
Dim nb As Button
nb = New Button

(set all button parameters here)
Controls.Add(nb)
tiles(i) = nb
Next


: