0% found this document useful (0 votes)
6 views8 pages

VB 08

Uploaded by

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

VB 08

Uploaded by

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

LECTURE-08

Working with Controls:


Creating and using controls, working with control arrays.

Similar to arrays of variables, you can group a set of controls together


as an array. The following facts apply to control arrays:
 The set of controls that form a control array must be all of the same
type (all textboxes, all labels, all option buttons, etc.)
• The properties of the controls in the control array can vary: i.e., some
members can be visible or not, they can be sized differently, they can
have different fonts or colors, etc.
• To refer to a member of a control array, the syntax is:
ControlName(Index)[.Property]
• To build a sample application that uses a control array, perform the
following steps:
• Start a new VB project. Place a command button toward the bottom
of the form and set its properties as follows:
• Property Value
• (Name) cmdTest
• Caption First
The ComboBox
• 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.
• Private Sub Form_Load ( )
• Combo1.AddItem "Item1"
• Combo1.AddItem "Item2"
• End Sub
The CheckBox
• The Check Box control lets the user selects or unselects an option.
When the Check Box is checked, its value is set to 1 and when it is
unchecked, the value is set t
The OptionButton
• The OptionButton control also lets the user selects one of the choices.
However, two or more Option buttons must work together because as
one of the option buttons is selected, the other Option button will be
unselected. o 0.
CONTROL ARRAYS

• Similar to arrays of variables, you can group a set of controls together as an array. The
• following facts apply to control arrays:

• The set of controls that form a control array must be all of the same type (all
textboxes, all labels, all option buttons, etc.)
• You set up a control array by naming one or more controls of the same type
the same name and set the Index property of each control in the array to a non-
negative value (i.e., the controls in the control array are usually indexed from 0 to one
• less than the number of controls in the array).
• To refer to a member of a control array, the syntax is:
• ControlName(Index)[.Property]

• For example, to refer to the Text property of the first element of an


array of textboxes called txtField, you would use:

• txtField(0).Text

You might also like