-
Dec 14th, 2013, 01:35 PM
#1
Thread Starter
New Member
Visual Studio 2013- Newbie- Buttons Click Text Change
Hey all,
I've just started playing around with Visual Studio 2013. I'm trying to get used to it, I don't have much programming experience, except for a bit of Python. Anyways, I have the following question:
I created a button. I would like the button to change its text each time its clicked. I managed to do it for a single click, by using the Click event and doing Button.Context = "blah", hence changing the text on the button from its initial value to blah. But now I would like to change this text 'blah' to something else, when the button is clicked for the 2nd time, and change it to something else again, when the button is clicked again. How would I do this?
Thanks for the help in advance! 
PS: I'm not sure if this is the right category to post this in, please move it if you feel it belongs somewhere else...thanks!
-
Dec 14th, 2013, 04:47 PM
#2
Re: Visual Studio 2013- Newbie- Buttons Click Text Change
Define static counter and increase it each click and according to its value change the text, e.g.
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Static c As Integer
c += 1
If c = 1 Then
Button1.Text = "blah 1"
ElseIf c = 2 Then
Button1.Text = "blah 2"
ElseIf c = 3 Then
Button1.Text = "blah 3"
c = 0 ' reset the counter
End If
End Sub
-
Dec 14th, 2013, 05:03 PM
#3
Thread Starter
New Member
Re: Visual Studio 2013- Newbie- Buttons Click Text Change
Thanks a lot, appreciate the help!
Another question, could you please suggest some really good resources for me to learn from, since I'm new to visual studio?
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
|