troubleshooting Question

How do I have a button repeat an action for as long as I have the button depressed?

Avatar of indy500fan
indy500fan asked on
Visual Basic.NET
5 Comments1 Solution260 ViewsLast Modified:
Friends,

I tried the following, but it never stopped the process when I released the mouse button:

    Private Sub btnFaster_Hold(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnFaster.MouseDown
        While Control.MouseButtons() = Windows.Forms.MouseButtons.Left
            If tbSpeedThreshold.Value < 20 Then
                tbSpeedThreshold.Value += 1

                System.Threading.Thread.Sleep(500)
                If Control.MouseButtons. = Windows.Forms.MouseButtons.None Then
                    SetSpeedThreshold()
                    Exit Sub
                End If
            End If
        End While
    End Sub
ASKER CERTIFIED SOLUTION
Jorge Paulino
IT Pro/Developer
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros