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?!
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.
Re: Random number by button Clicked... accessed in a loop!!
Quote:
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.
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.