AnsweredAssumed Answered

Determine mouse status to increase or decrease a value

Question asked by Harold Black on Jan 16, 2020
Latest reply on Jan 17, 2020 by Harold Black

I have a userform with a 2 labels showing arrows; this replaces the spinner object one would typically use to increase/decrease a value. The reason why I'm using labels is because I'm changing how the up and down arrows look depending on the following states of the mouse: not over the label, hovering over it, clicking or holding left mouse button on the arrow label. This isn't what's important.

 

The problem I'm having is that I can't figure out a way to increase or decrease a number I have in a textbox as I'm holding down one of the arrow "buttons". I want to show the number increasing or decreasing as the mouse button is held down. I can get the value to change right after a MouseDown event but not for a continuous MouseDown hold .My suspicion is that I will have to have a Do Loop within the MouseDown event. I'm at a loss here, I've tried timers and I'm running out of ideas. Any help would be great.

 

Update:

I found some code that does what I'm looking for. Now I just need to modify the code to allow a user a single click.

 

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Do While GetAsyncKeyState(1)
Caption = "Rewinding"
'do your rewinding here
DoEvents
Loop
Caption = "Paused"
End Sub

Attachments

Outcomes