Results 1 to 3 of 3

Thread: detecting mouse clicks in a control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    detecting mouse clicks in a control

    Hi folks, I am a VB newbie, trying to learn VB with the basic online tutorial that came with VB 2008 Express.

    I would like the text in a button to display "hello" when it is first clicked, and "world" when it is clicked again. But I don't know how to write code to detect the second click.

    I've used the forum search to find threads with "mouse clicks" in the topic, and have read at least a dozen of them, but they do not help.

    Thanks in advance.

    ==========================================================
    Private Sub StartStopButton_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StartStopButton.MouseClick
    Button1.Text = "Hello"

    Button1.Text = "world"

    End Sub
    =========================================================

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: detecting mouse clicks in a control

    You need a member variable, i.e. declared at the class level, to store a value that indicates what click you're on. You can then the current value of that variable to decide what to do on the current click, then set it for the next click.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Re: detecting mouse clicks in a control

    Thanks jmcilhinney

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width