Click to See Complete Forum and Search --> : I need help with a game i wanna make
Lord Rayv3n
Jun 25th, 2002, 06:47 PM
im including a pic. each one of the buttons are OptionButton, and what i need is way to get a random button to become true when the current button that is true is clicked.
oh and also need a way to count how many buttons the player has clicked.
i would be greatfull for any help i could get.
http://209.120.143.185/attachment.php?s=&attachmentid=14650
110359
Jun 25th, 2002, 09:44 PM
The easy way to keep count of how many buttons has been pressed is to use a text box or label. I'll assume the label is called count and I'll just use button1.
This code should be put into the buttons command:
count.caption = count.caption + 1
Just put that in for every button.
Lord Rayv3n
Jun 25th, 2002, 10:30 PM
thanx, that answered one of my questions
110359
Jun 25th, 2002, 10:48 PM
Glad to be of asistance. I'm not 100% sure of how to get a random button selected, but it probably needs something like a control array.
110359
Lord Rayv3n
Jun 26th, 2002, 02:37 AM
well im not sure.
and when i thought about this game i thought it would be an easy one. lol
it was easier to make a mp3 player that doesnt s rely on the windowsmedia.ocx
Fishfood
Jun 28th, 2002, 03:10 AM
to have that random stuff, cant you just give each button a number and then make the program make a random nunber and....yeah, see what i mean?
or give each row a number, each coloumn a number and do the same thing?
RuneLancer
Jul 1st, 2002, 09:32 PM
To keep track of how many clicks there are, you just need a variable. Let's suppose we call it n_Clicks. You'd do n_Clicks = n_Clicks + 1 every time a button is clicked.
As for a random button being selected... It would be much easier to create a control array. Just create a single button in the upper-left corner and call it, say, ClickButton. Give it the index '0'. Next, using for... to...'s, spawn all your buttons in your Form_Load. They'll all have a unique number. Create a variable to hold the current button being clicked (like, say, CurrentButton). When the user clicks it, do the following...
ClickButton(CurrentButton).value = vbunchecked
CurrentButton = int(rnd * (max amount of buttons))
ClickButton(CurrentButton).value = vbchecked
CodeRonin
Jul 5th, 2002, 01:13 AM
Ok, as for the first question:
I wouldn't use a variable, for you'd need a global one (or a static one) which kinda sucks. I'd use a hidden TB.
For the second part I agree with Lancer, a ControlArray would be fine, and then just ControlArray.Add new OB's in a loop to build your form....
You can then ControlArray(rnd(1)*whatever)=true.
Hope this Helps,
CodeRonin
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.