next up previous
Next: About this document ... Up: VisualBasic Previous: 20. Arrays

21. Horizontal and Vertical Scroll Bars

There are two more useful icons in the Toolbox that we haven't yet investigated. These are the Horizontal and Vertical Scroll Bars HScrollBar and VScrollBar. Move your cursor over the icons which look like a rectangle with arrows at each end. (There is one which is vertical and one which is horizontal.)

Now start a new project (which can be done by going to the File menu item in the VisualBasic environment, and selecting the New Project option!).

Place a command button and a VScrollBar on the form. Edit the Properties of the VScrollBar so that its Max is 100 and its Min is 0.

Now enter the following code:

Private Sub Command1_Click()

Print Val(VScroll1)

End Sub

When you run this program, before you click on the Command1 button, move the position of the indicator in the VScrollBar to a new position. You will see the numerical value that the VScrollBar indicator is set at appear on the screen.

Note that instead of using Val(VScroll1) you could equally use VScroll1.Value

Here is another, slightly more sophisticated programme which prints out the value of the scroll bar for you to play with!

HScrollBar and VScrollBar can be used to input values into a program just like TextBoxes (see [*]). The obvious difference is that they provide a more graphical/mouse based method compared with TextBoxes.


next up previous
Next: About this document ... Up: VisualBasic Previous: 20. Arrays
Chris Allton 2006-10-27