What i am trying to do with a scroll bar is when the value is increased by a certain value do a command. If the value is decreased then do a different command. Is this possible?
Printable View
What i am trying to do with a scroll bar is when the value is increased by a certain value do a command. If the value is decreased then do a different command. Is this possible?
Hello
This should work, i hope.
VB Code:
Dim oldval Private Sub VScroll1_Change() If VScroll1.Value - oldval = 10 Then MsgBox "decrease" oldval = VScroll1.Value ElseIf VScroll1.Value - oldval = -10 Then MsgBox "increase" oldval = VScroll1.Value End If End Sub
Hmmmm .. Not exactly what i need to do i should rephrase.
ON scrollbar value decrease Do This
On Scrollbat value increase Do That
How woudl i do this?
Ive tried this but i only get the increase messege
Private Sub VScroll1_Change()
If VScroll1.Value > oldval Then
Debug.Print "increase"
oldval = VScroll1.Value
Else
Debug.Print "Decrease"
oldval = VScroll1.Value
End If
End Sub
Try setting a module level variable to hold the old value. Assign that varible the current value of the scrollbar. Compare that veriable with the new value of the scrollbar when the Change event occurs. Then, on the Change event, after your code, update that variable. This will prepare it for the next Change event.
Actually, I just looked at your code more closely, and that is probably what you already have. I don't see what it is, but there must be a reason that the value is always greater than the old value.