Results 1 to 6 of 6

Thread: Scroll bar help needed

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2004
    Posts
    129

    Question 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?

  2. #2
    Registered User HellRaider's Avatar
    Join Date
    Sep 2003
    Posts
    70

    Re: Scroll bar help needed

    Hello
    This should work, i hope.
    VB Code:
    1. Dim oldval
    2. Private Sub VScroll1_Change()
    3. If VScroll1.Value - oldval = 10 Then
    4.     MsgBox "decrease"
    5.     oldval = VScroll1.Value
    6. ElseIf VScroll1.Value - oldval = -10 Then
    7.     MsgBox "increase"
    8.     oldval = VScroll1.Value
    9. End If
    10. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2004
    Posts
    129

    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?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2004
    Posts
    129

    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

  5. #5
    Addicted Member
    Join Date
    Nov 2004
    Posts
    171

    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.

  6. #6
    Addicted Member
    Join Date
    Nov 2004
    Posts
    171

    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
  •  



Click Here to Expand Forum to Full Width