Visual Basic6
Visual Basic6
Visual Basic6
In order to add items to the list, we can use the AddItem method.
For example, if you wish to add a number of items to list box1, you can key in the following
statements.
The items in the list box can be identified by the ListIndex property, the value of the ListIndex
for the first item is 0, the second item has a ListIndex 1, and the second item has a ListIndex 2
and so on.
Combo Box
The function of the Combo Box is also to present a list of items where the
user can click and select the items from the list.
However, the user needs to click on the small arrowhead on the right of
the combo box to see the items which are presented in a drop-down list.
In order to add items to the list, you can also use the AddItem method.
For example, if you wish to add a number of items to Combo box 1, you
can key in the following statements
Example 3.3
Private Sub Form_Load ( )
Combo1.AddItem “Item1”
Combo1.AddItem “Item2”
Combo1.AddItem “Item3”
Combo1.AddItem “Item4”
End Sub
Check Box
The Check Box control lets the user to select or
unselect an option.
When the Check Box is checked, its value is set to 1
and when it is unchecked, the value is set to 0. You
can include the statements Check1.Value=1 to mark
the Check Box and Check1.Value=0 unmark the Check
Box, and use them to initiate certain actions.
For example, the program will change the background
color of the form to red when the check box is
unchecked and it will change to blue when the check
box is checked.
Option Box
The Option Box control also lets the user selects one of the
choices.
However, two or more Option Boxes must work together because
as one of the Option Boxes is selected, the other Option Boxes
will be unselected.
In fact, only one Option Box can be selected at one time. When an
option box is selected, its value is set to “True” and when it is
unselected; its value is set to “False”.
In the following example, the shape control is placed in the form
together with six Option Boxes. When the user clicks on different
option boxes, different shapes will appear.
The values of the shape control are 0, 1, and 2,3,4,5 which will
make it appear as a rectangle, a square, an oval shape, a
rounded rectangle and a rounded square respectively.
Option Box Example
Private Sub Option1_Click ( )
Shape1.Shape = 0
End Sub
Private Sub Option2_Click()
Shape1.Shape = 1
End Sub
Private Sub Option3_Click()
Shape1.Shape = 2
End Sub
Private Sub Option4_Click()
Shape1.Shape = 3
End Sub
Private Sub Option5_Click()
Shape1.Shape = 4
End Sub
Private Sub Option6_Click()
Shape1.Shape = 5
End Sub
Driver List Box
The Drive ListBox is
used to display a list of
drives available in your
computer. When you
place this control into the
form and run the
program, you will be able
to select different drives
from your computer as
shown in Figure.
Directory List Box
The Directory List Box is
used to display the list of
directories or folders in a
selected drive.
When you place this
control into the form and
run the program, you will
be able to select
different directories from
a selected drive in your
computer as shown in
Figure
File List Box
major data types, they are numeric data type and non-
Data Types
Non Numeric
Numeric Data Type
Data Type
Numeric Data Type
Non Numeric Data Type