0% found this document useful (0 votes)
18 views

Lesson X

This document provides a lesson on using horizontal and vertical scrollbars. It defines the objectives as using scrollbars to select from ranges of values and manipulate other controls. It describes the fundamental properties of scrollbars like LargeChange, Max, Min, SmallChange, and Value. It provides an example of using a horizontal scrollbar to manipulate the font size of a label by associating the scrollbar's Value property to the label's FontSize property. Learners are instructed to create this example application.

Uploaded by

whoekirksvih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lesson X

This document provides a lesson on using horizontal and vertical scrollbars. It defines the objectives as using scrollbars to select from ranges of values and manipulate other controls. It describes the fundamental properties of scrollbars like LargeChange, Max, Min, SmallChange, and Value. It provides an example of using a horizontal scrollbar to manipulate the font size of a label by associating the scrollbar's Value property to the label's FontSize property. Learners are instructed to create this example application.

Uploaded by

whoekirksvih
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lesson X.

Horizontal and Vertical Scrollbars

Objectives
  To be able to use Horizontal and Vertical Scrollbar controls to select from ranges of values.
  To be able to use Scrollbars to manipulate other controls.

Notes
Scrollbars let users control value changes. Rather than type specific values, the user can move the scrollbar
with the mouse to specify relative positions within a range of values. There are two types of scrollbars:
Horizontal and Vertical Scrollbars. Except for their orientation, they share exactly the same properties.

Example of a Horizontal Scrollbar (Left) and a Vertical Scrollbar (Right)

The following are the fundamental properties of a scrollbar.

Property Description
LargeChange Specifies the amount that the scrollbar’s Value property changes
when the user clicks within the scrollbar’s shaft area.
Max Indicates the maximum number of units that the scrollbar value
represents at its highest setting. The range is from 1 to 32,767 (the
default Max value)
Min Indicates the minimum number of units the scrollbar value represents
at its lowest setting. The range is from 1 (the default Min value) to
32,767.
SmallChange Specifies the amount that the scrollbar’s Value property changes
when the user clicks an arrow at either end of the scrollbar.
Value Contains the units of measurement currently represented by the
position of the scrollbar.

When you place a scrollbar on a Form, set the range of values the scrollbar is to represent. Set the Min and
Max property to the lowest and highest value the scrollbar will represent, respectively. When the user
eventually clicks any arrow in the scrollbar, the Value of the scrollbar will change (positive SmallChange when
the right or up arrow is clicked; negative SmallChange when the left or down arrow is clicked).

Lesson in Action
Let’s use the ScrollBar in a simple application. In the Form below, the ScrollBar will be used to
manipulate the font size of the Label. The main task is simply to associate the Value property of the
scrollbar to the FontSize property of the Label. Thus, changing the ScrollBar’s Value will subsequently
change the FontSize of the Label.

50
1. Create the Form displayed above.
2. Drag a Label control to the Form and set the following properties:
  Name lblBanner
  Caption Visual Basic
  FontSize 8
  FontStyle Arial
  BackColor Yellow

3. Drag a HScrollBar to the Form and set the following properties:


  Name hsbFSize
  Min 8
  Max 35
  Value 8
The Max value also determines the maximum font size of the label. Tip: Assign the maximum font
size of the caption that can fit within the Label to the Value property of the HScrollBar. The initial
value of the Value property should match the initial FontSize of the Label’s caption.

4. Write the following procedure:

Private Sub hsbFSize_Change()


LblBanner.FontSize = hsbFSize.Value
End Sub
5. Run your application.
6. Save your work as Lesson10.vbp.

On your Own

1. Create a program that manipulates the position of the Label in the Form using Vertical and
Horizontal Scrollbars. Note: Make sure that the Label does not go beyond the rectangular Shape control.

2. Modify the program you have made in the Lesson in Action section. Display the current font size in a
Label.

51

You might also like