Scroll Bars in Visual Basic 6


In this lesson, you will learn about the scroll bars - Vertical and Horizontal.

You have seen scroll bars in most of the Windows applications. A scroll bar is a very important element of a software. When you'll work on a software project in VB6, you'll need these controls if you have to scroll down or scroll up a page.

Two types of scroll bars are there in the Visual Basic environment -- HScrollBar (Horizontal Scroll Bar) and VScrollbar(Vertical Scroll Bar).


Most useful properties

The main properties of both the scroll bars are Min, Max, SmallChange, LargeChange and Value. 


Vertical scroll bar

screenshot of the VScrollBar



Value

The Value property returns the scroll bar position's value. Each position of the thumb has a value. The Value changes when you click on one of the arrow buttons or when you move the thumb by dragging it.


Min

The Min property sets/returns the minimum value of a scroll bar position.

Max

The Max property sets/returns the maximum value of a scroll bar position.



SmallChange

The SmallChange property sets/returns the amount of change to Value property in a scroll bar when the user clicks on a scroll arrow button.



LargeChange

The LargeChange property sets/returns the amount of change to Value property in a scroll bar when the user clicks on the scroll bar area.

The Change event fires when an arrow button or the scroll bar area is clicked or after the thumb has been dragged. The Scroll event is raised when the thumb is being dragged.

Sample: VScrollBar demo


The following sample program will help you easily learn about the scroll bars. 

Download sample program: Length Converter


In some cases, you do not need to use scroll bars as many controls in VB6 provide a scroll bar with them. For example, the TextBox control has a scroll bar with it, and it becomes enabled when you set the Multi-Line property of the TextBox control to True .