DISCOVER
×

How to Use ScrollBar in VB6

Updated July 20, 2017

The ScrollBar allows you to scroll up and down the page of your web browser. That is a vertical ScrollBar. Visual Basic has vertical and horizontal ScrollBars. The controls are located in the Toolbox and are named "HScrollBar" and "VScrollBar." In addition, some VB controls also have built-in scrolling abilities such as the ComboBox, ListBox, TreeView and ListView controls. A bit of extra coding is required to use the separate scroll bars to provide scrolling to other controls such as a PictureBox, Frame or the Form itself.

Create a new Standard EXE Visual Basic project. Select the Label control and add it to the form, named "Form1" by default. The default name for the Label is "Label1."

Select VScrollBar from the VB Toolbox and add it to the form to the right of "Label1." Resize it till the top of "VScroll1" is at the top of "Label1" and the bottom of each control lines up as well.

Set the Max, Min and LargeChange properties for "VScroll1." Set the Min to 1 and the Max to 10. The LargeChange number is how much the ScrollBar should move when the user clicks the ScrollBar area. When the user clicks the down or up arrows, the ScrollBar moves by the "Value" property amount. Set LargeChange to 2 and Value to 1.

Change the value of "Label1" each time "VScroll1" is clicked by coding "Label1.Caption = VScroll1.Value" in the "VScroll1_Change" event.

Use the "Move" method of "Label1" to actually move up and down within the Label control each time "VScroll1" is clicked. To move down, subtract from the "Top" property of "Label1." This code should also be placed within the "VScroll1_Change" event.

Tip

Edit the Min, Max and LargeChange values of the ScrollBar control to suite the needs of your specific application.

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Lora Covrett has been writing professionally since 2006. She has published a humor book, as well as articles for various online publications. Covrett is an IBM-certified database administrator and solution expert. She completed her Bachelor of Science in computer information systems at Devry University.