|
-
Jan 7th, 2005, 05:02 AM
#1
Thread Starter
Addicted Member
Scroll bar help needed
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?
-
Jan 7th, 2005, 05:06 AM
#2
Registered User
Re: Scroll bar help needed
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
-
Jan 7th, 2005, 05:26 AM
#3
Thread Starter
Addicted Member
Re: Scroll bar help needed
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?
-
Jan 7th, 2005, 05:29 AM
#4
Thread Starter
Addicted Member
Re: Scroll bar help needed
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
-
Jan 7th, 2005, 06:51 AM
#5
Addicted Member
Re: Scroll bar help needed
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.
Sherminator ~ I'll be back.
-
Jan 7th, 2005, 06:53 AM
#6
Addicted Member
Re: Scroll bar help needed
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.
Sherminator ~ I'll be back.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|