Each time I click on button display sum
I am clicking on button which is equals to 5, i want the label to display updated number each time i click on button, so 1 button click = 5 on label, 2 button clicks = 10 on label, etc.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Feb 20, 2012, 10:21 PM
Then your code will be more like this:
anteLabel.Text = number.ToString();
Note that that code does not show the one line that declares the number.
Prime bPosted Feb 20, 2012, 10:29 PM
Prime bPosted Feb 20, 2012, 9:25 PM
And my question is this
private void chipBet5Button_Click(object sender, EventArgs e)
{
int number = +5;
anteLabel.Text = ""+number ;
}
each time I click chpBet5Button I want anteLabel.Text to display the number! So, as you can see, the number is equals to 5 with first click, but if I click it twice it just displays 5 again........ it doesn't add 5 to number second time, it kind of resets!
Sam HobbsPosted Feb 20, 2012, 9:20 PM
Think about it. Think about what is needed. It is extremely easy to do if you think about it. You will need a count of the nuber of times the button has been clicked. Each time the button is clicked, increment the count, then convert that count (multiply by 5) to the value you need to show. Then convert the value to a string and then set the button's Text property to that value. If you have any questions about that then please ask a specific question.