Visual Studio 2013- Newbie- Buttons Click Text Change-VBForums
Results 1 to 3 of 3

Thread: Visual Studio 2013- Newbie- Buttons Click Text Change

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2013
    Posts
    2

    Question 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!

  2. #2
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    1,699

    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2013
    Posts
    2

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.