|
-
May 22nd, 2012, 03:16 PM
#1
Thread Starter
New Member
Random number by button Clicked... accessed in a loop!!
I was working in a Game in VB, and I was making a Loop that will start when the game begin and end when someone win.
But then I found a problem:
I have my main code in the loop and a Randomizer that starts when a button is clicked.
So my problem is that I can't work whit the random number in my loop.
How can I access the random number (it as to be choosen after a click of a button) in my loop?!
-
May 22nd, 2012, 04:20 PM
#2
Re: Random number by button Clicked... accessed in a loop!!
The variable would have to be declared at a scope that is visible to both parts of the code. Other than that I can't say without seeing the code.
My usual boring signature: Nothing
 
-
May 22nd, 2012, 11:44 PM
#3
Re: Random number by button Clicked... accessed in a loop!!
 Originally Posted by AlexCavaco7
I was working in a Game in VB, and I was making a Loop that will start when the game begin and end when someone win.
That sounds wrong for a start. A WinForms app that has a single loop running for the duration of the session? I can't think of a situation where that would be appropriate. WinForms is an event-driven GUI technology. The app should just sit there until the user does something, e.g. clicks a Button. You would handle the Click event and then do something in the event handler.
-
May 23rd, 2012, 09:25 AM
#4
Re: Random number by button Clicked... accessed in a loop!!
Typical game loop, actually, though that is usually not in a WinForms app. However, the OP didn't actually say that this WAS WinForms....though it is strongly implied based on a couple statements in there.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|