Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How to stop a looping messagebox ?

$
0
0

I got a textbox in which there's a score set to 50.

Whenever I press a button, I want it to minus 1 from that textbox and place it to another, so that the ending result after pressing the button one time would be:

textbox1 = 49

textbox2 = 1

I've created a new button class that makes the button able to loop as long as it's pressed, so that keeps adding " 1 " to the textbox2 and while doing this keeps subtracting 1 to texbox1. (using timer ticks)

Back In the Form Class, inside the private void button_Click(object sender, EventArgs e) saying that    if textbox1 > 0, does the trick, so textbox1 value = -1 and textbox2 value = +1

the problem came when I reach the zero and a messagebox appears telling that i've got no points, since while pressing the button that messagebox keep looping and get repeated on screen multiple times, how would you fix this ?

Thanks in advance for the answers


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>