Determine mouse status to increase or decrease a value

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

SolidworksApi/macros
Answers 2
FR
FR 2021-04-08 Best Answer

Hello, try this:

Private ChangeVal As Boolean

Private Sub ChangeValue(ByVal incr As Integer)
instancesTxtBox.Text = Val(instancesTxtBox.Text) + incr
If Val(instancesTxtBox.Text) < 2 Then instancesTxtBox.Text = 2
Dim TimeEnd As Single
TimeEnd = timer + 0.1
Do Until timer > TimeEnd
DoEvents
Loop
If ChangeVal Then ChangeValue incr
End Sub

Private Sub UpArrow_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
UpArrow.Picture = LoadPicture(UpArrow_highlightPath)
SelText instancesTxtBox, False, "select"
ChangeVal = False
End Sub

Private Sub UpArrow_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
DownArrow.Picture = LoadPicture(DownArrow_defaultPath)
SelText instancesTxtBox, True, "unselect", UpArrow.Object, UpArrow_mouseclickPath
ChangeVal = True
ChangeValue 1
End Sub

Private Sub DownArrow_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
DownArrow.Picture = LoadPicture(DownArrow_highlightPath)
SelText instancesTxtBox, False, "select"
ChangeVal = False
End Sub

Private Sub DownArrow_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
instancesTxtBox.ForeColor = RGB(0, 0, 0)
UpArrow.Picture = LoadPicture(UpArrow_defaultPath)
SelText instancesTxtBox, True, "unselect", DownArrow.Object, DownArrow_mouseclickPath
ChangeVal = True
ChangeValue -1
End Sub

SC
SC 2021-04-08

Thank you, this works also. A solution that doesn't involve mouse key state in windows.