|
|
The range of integers the horizontal scroll bar can represent is set by the max and min properties. |
|
|
The scroll bar does not have a caption property. In order to see the value of the scroll bar, you must use a label. |
|
|
The value property specifies the initial value of the scroll bar. |
|
|
The amount the scroll bar changes when click on an arrow is controlled by the smallchange property |
|
|
The amount the scroll bar changes when click a the open area between the handle and the arrow is controlled by the largechange property |
|
|
The Change event occurs whenever the value of the scroll bar changes. |
Example
The following program allow the use to input a number between 1 and 100.

| Scroll Bar | Name
= hsbScroll1 Value = 50 smallchange = 1 largechange = 5 |
| Label | Name
= lblValue Caption = "50" Alignment = Center |
Private Sub hsbScrollBar1_Change()
lblValue.Caption = hsbScrollBar1.Value
End Sub
![]()
Option Boxes and Check Boxes
Option buttons (AKA Radio buttons) allow the user to choose from many choices. They must choose 1 and only 1 option. Choosing 1 "unchooses" the rest! Option buttons look like this:
Check boxes are used when the user may choose as many selections as they would like (including zero!). Here is what check boxes look like.
Write a program that uses option buttons to set a font size and check boxes to select font style.
Design the Interface

Set The Properties

lblTestFont
Alignment = Center Caption = "Test Font Style" FontSize = 14 optSmallFont
Caption = "Small Font" Value = "True" chkBold
Caption = "Bold" Value = "0- unchecked"
Write the Code
For the option button, the code is simple. If it is clicked, set the font to the small size. Since the control automatically is linked to the other option button, that's all you have to do.
Private Sub optSmallFont_Click()
lblTestFont.FontSize = 14
End Sub
The check boxes are a little more complex. Use and If..Then to determine the status. This type of control is called a switch in programming.
Private Sub chkBold_Click()
If chkBold.Value = 0 Then
lblTestFont.FontBold = False
Else
lblTestFont.FontBold = True
End If
End Sub
Now we can design the first version of our Word Processor.
Select New Form from the File
Menu and Design the form as below

|
Object |
Name |
Properties |
|
Form |
frmWord |
BackColor
= Make it blue |
|
Command Button |
cmdClear |
Caption
= "&Clear" |
|
Command Button |
cmdExit |
Caption
= "E&xit" |
|
Text Box |
txtFontSize |
Alignment =
Center |
|
Scroll Bar |
HSBFontSize |
LargeChange
= 4 |
|
Check Box |
chkItalics |
BackColor
= Make it blue |
|
Check Box |
chkUnderline |
BackColor
= Make it blue |
|
Check Box |
chkBold |
BackColor
= Make it blue |
|
Option Button |
optSchoolbook |
BackColor
= Make it blue |
|
Option Button |
optArial |
BackColor
= Make it blue |
|
Option Button |
optSansSerif |
BackColor
= Make it blue |
|
Text Box |
txtText |
FontBold
= False |
|
Label |
Label3 |
Alignment
= Center |
|
Label |
lblFontType |
BackColor
= Make it blue |
|
Label |
lblFont |
BackColor
= Make it blue |
|
For chkBold: If chkBold is false Then set
Font bold in text widow to False Else
set Font bold in text widow to True |
For chkItalics set
Font Italic in text window to False Else set Font Italic |
|
For HSBFontSize set text.window font size
to HSB Font size |
For optArial If its value is True Then
txtText.FontName = "Arial" |
|
For chkUnderline If
its underline value is False Then
set Font underline in text window to False Else set Font underline in text
window to False |
For optSansSerif If its’ value is True
set Font name to "MS Sans Serif" |
![]()