View Single Post
Old 12-06-2006, 09:15 AM   #4 (permalink)
Meithan
 
Ultra Techie

Join Date: Jul 2006

Posts: 714

Meithan is on a distinguished road

Send a message via AIM to Meithan Send a message via Yahoo to Meithan
Default

If the buttons are always the same, but what changes is which is the correct button to push, then it's very simple (the last post almost gave it away): when the form opens, randomize an integer (from 1 to the number of buttons you want). Then, just assign a number (in your head) to each button and put a check in the button's code: if the random number matches the preset number for that button, then you go to the next form.

On Form load:
Randomize()
RndNum = Int(Rnd() * n + 1) //where "n" is th number of buttons

Buttons:
Button1_Click: "If RndNum=1 Then form2.show"
Button2_Click: "If RndNum=2 Then form2.show"
etc...

Since the correct button is fixed, all he'll have to do is click them all until one works (rather silly). If you want to randomize the buttons again after he makes a try (so he really has to guess), just put the RndNum = Int(Rnd() * n + 1) line in the code of each button before the check.

Hope this helps.

Edit: by the way, are you using VB6 or VB.NET (or even DOS Basic)?
__________________


SuperPi 1M: 29.6s - 3DMark06: 8616
The Geek Test v3.1 Score: 36.3% - Major Geek
Meithan is offline