How to Program a Vertical Scroll Bar in Visual Basic 6.0


Vertical scroll bars are components in Visual Basic that allow users to move a text box or form up or down. It's used mainly in applications where there is more information on the screen than can be seen on the user's display settings. Learning how to work with the Visual Basic scroll bars adds a better user interface for applications.

  • Add the vertical scroll control to the Windows form. The scroll control is in the Visual Basic toolbar that is located in the workspace of the application. Double-click the icon on the toolbar or drag and drop it onto the form.

  • Set the indicator to the top of the scroll bar. The indicator is the component within the scroll bar that tells the user at what location he is on the form. For instance, if the indicator is in the middle of the scrollbar, then the user is in the middle of the form. Set the indicator at the top when the user first enters the Windows form. The code example is below:

    myScrollbar.Value = myScrollbar.Min

  • Set the scroll bar's value in a text box. In this example, the user increases or decreases a number by clicking on the scroll bar. This is useful in applications where a preset range of numbers is entered into a text box. The programmer needs to keep track of these changes and display the current location in the field. The code below reflects a changed number when the user clicks the "up" or "down" arrow on the scroll bar:

    myNumber.Text = myScrollbar.Value

  • Move an image on a form when the user clicks the scroll bar. The code below uses the scroll bar to move an image:

    myCanvas.Move myScrollbar.Value

  • Set focus to the scroll bar. The code below sets focus to the scroll bar. This is beneficial when you want to prompt the user to click the scroll bar to enter a number or view a document.


Related Searches


Promoted By Zergnet


You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!