Results 1 to 7 of 7

Thread: how to use a scrollbar

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    www.mechboxer.de
    Posts
    15

    how to use a scrollbar

    hi,
    I am a noob in vb and now I want to create a form with a vertikal scrollbar at the right border.
    but how can I make it, that the scrollbar scrolls ?!
    I only have text written in this form and only want it to scroll down...
    perhaps you can help me and write and example or so...

    thanx a lot,

    stylewriter
    -=|www.mechboxer.de|=-

  2. #2
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    If you want to know if the scroll bar has been scrolled, check out the event subroutine as you would for the other controls. Use the scroll/change event.
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  3. #3
    Lively Member da_haCKEr's Avatar
    Join Date
    Oct 2002
    Location
    Paradise Isle of Sri Lanka
    Posts
    116

    Wink Hmm

    Well, If you're trying to scroll the text that you output to the form using the Print method, you have to do some work to preserve the text. But the easiest way is to just use a Text Box with the MultiLine Property set to true. It will automatically scroll upwards and Downwards.

    Anyway, you can get the value of the scrollbar by putting code into the VScrollBar1_Scroll event or VScrollBar1_Change event.
    To get an Idea, do the following.

    VB Code:
    1. Private Sub VScrollBar1_Scroll
    2. Text1.Text = VScrollBar1.Value
    3. EndSub
    .:JanuZ:.
    .:JanuZ:.XtremeSoft


  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    www.mechboxer.de
    Posts
    15
    sorry guys, I am a total noob
    can you perhaps post how I can scroll down with labels?
    I have got several labels (named Label1, Label2,...) in a form and want to scroll them up / down...
    -=|www.mechboxer.de|=-

  5. #5
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    I have no VB Access right now. But from the top of my head...

    VB Code:
    1. 'In a form
    2. Dim LastV as Integer
    3.  
    4. Private Sub Form_Load()
    5. LastV = VScrollBar1.Value
    6. End Sub
    7.  
    8. Private Sub VScrollBar1_Scroll()
    9.      'Move the label depending on the scroll
    10.      'If the scroll value increases, subtraction will become addition
    11.      Label1.Top = Label1.Top - (LastV - VScrollBar1.Value)
    12.      'Save the Last scroll value
    13.      LastV = VScrollBar1.Value
    14. End Sub

    Add a scrollbar (VScrollBar1) and a label (Label1) to the form
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    www.mechboxer.de
    Posts
    15
    oukei, now the scrolling is possible.
    but only in one way
    if I press the up or down button the labels scroll down!
    if I change the - with + it only scrolls upwards.
    how have I got to set the values of the scrollbar?
    the max, min, value - values...
    sorry about these stupid questions
    -=|www.mechboxer.de|=-

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Location
    www.mechboxer.de
    Posts
    15
    I found my mistake!
    Everything is allright now

    thanx a lot!!!
    -=|www.mechboxer.de|=-

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