P1: IML
Owen WL040/Bidgolio-Vol I WL040-Sample.cls June 20, 2003 17:37 Char Count= 0
VISUALBASICLANGUAGEELEMENTS 615String
String is a field of at least 12 bytes and a maximum limited
only by the computer hardware. It is capable of holding
from 0 to approximately 2 billion Unicode characters.Variant
The variant data type available in Visual Basic 6.0
and earlier versions does not exist in Visual Basic.NET
(Evjen & Beres, 2002). Variables declared in the Variant
data type can hold integers, real numbers, or character
strings. Variables created via the automatic variable dec-
laration mechanism are of the data type Variant. Elimina-
tion of the Variant data type from Visual Basic.NET made
support of the automatic variable declaration option im-
possible. Given the Variant data type’s inefficient use of
memory, the additional overhead needed to actively con-
figure memory usage to accommodate both numeric and
character string data, and the development problems dis-
cussed above, elimination of the Variant data type and
the automatic variable declaration option from Visual
Basic.NET is not considered a significant loss.Control Structures
Visual Basic offers a complete set of decision and rep-
etition control structures. Decision structures allow the
program to compare data items to determine which state-
ments to execute. Visual Basic includes the If, If...Else,
and Select Case decision control structures. Repetition
structures allow the program to repeat groups of state-
ments, called blocks, if certain conditions are met. Visual
Basic includes the pretest While loop, the pretest Until
loop, the posttest While loop, the posttest Until loop, and
the Counter Controlled loop. These control structures are
not unique to Visual Basic. Consult the bibliography for
text and reference books that cover the general function
and specific syntax of Visual Basic’s control structures.Common Controls
The Toolbox contains the control classes that can be in-
cluded in a Visual Basic program. It contains controls
commonly used in Windows programs. Additional con-
trols are available from other Microsoft sources and from
third party vendors. A control is selected from the tool-
box and placed on the form. Each control is given a
unique name. Controls in Visual Basic are object classes,
which have properties and methods defined for them.
These properties and methods are inherited by the con-
trol when it is created. Properties and methods associated
with a specific control are accessed using the. (read “dot”)
operator. The. operator is used to separate the control
name from the property or method being accessed. For
example,Label1.Captionwill access the Caption property of the Label control called
Label1. A value can be assigned to this property in the
same manner in which a value is assigned to a variable.Label1.Caption="Hello!"The following is a brief description of some of the
more commonly used controls. Unless specified other-
wise, these controls are available through the standard
Toolbox.Form
The Form can be considered a control. It has properties
and methods associated with it, but it is not on the Tool-
box. A form can be added to a project by selecting the Add
Item button on the Tool Bar, or from the Project menu in
the Menu Bar (Harriger et al., 1999).Label Control
The Label control is used to display text. It is often used to
identify the function of some other control, to display in-
formation generated by the program, and to display error
messages (Harriger et al., 1999). Through manipulation
of the Label’s properties, such attributes as the size and
shape of the display area and the font, the color, and the
number of lines of text displayed in the label can be spec-
ified.Text Box Control
The Text Box control is used to enter data. Text Box con-
trols inherit full editing capabilities on entered text. The
user can type, backspace, delete, and select text using
common Windows editing techniques (Harrington et al.,
1997).Command Button Control
The Command Button allows the user to initiate some ac-
tion. This action is usually initiated by clicking the com-
mand button (Harriger et al., 1999).Check Box Control
The Check Box control allows the user to select one or
more items from a list. By clicking the small box next
to the description of the item, the user can insert or re-
move a check mark. Instructions placed in the click-event-
handling module for the Check Box control determine
which boxes are checked and therefore which items the
user selected (Harrington et al., 1997).Option Button Control
The Option Button control functions similar to the Check
Box control, except that only one of the items in the list
can be selected. Selecting one item automatically dese-
lects all other items. Option Buttons are sometimes called
radio buttons because they function like the station se-
lection buttons on a car radio. Only one station can be
selected at any one time. Option Buttons are frequently
used with the Frame Control. The Frame control groups
the Option Buttons together and specifies which Option
Buttons work together. This allows two or more groups
of Option Buttons to operate independently on the same
form (Harrington et al., 1977).List Box Control
The List Box control is used to display a list of items.
Items may be added to and removed from the list via the
AddItem and RemoveItem methods, respectively. The user
may select an item from the list. The Text property of the