P1: IML
Owen WL040/Bidgolio-Vol I WL040-Sample.cls June 20, 2003 17:37 Char Count= 0
616 VISUALBASICList Box contains the selected item. The List Box can be
emptied by using the Clear method.Combo Box Control
The Combo Box control is a combination of the List Box
and Text Box controls. The Combo Box is a List Box with a
Text Box affixed to the top. The Text Box portion remains
visible whereas the List Box portion can be displayed or
hidden. An item selected from the Combo Box list is dis-
played in the Text Box. In many applications, the user
does not need to see the contents of the list once an item
has been selected. The Combo Box displays the complete
list while a selection is made, then hides the list to save
space on the form. The Text Box portion of the Combo
Box remains visible, keeping the selected item visible on
the form.Modularity: Functions and Procedures
The sheer size and scope of business applications require
that they be broken down into smaller, more manageable
units. Each unit contains a relatively small block of code
that addresses one task or aspect of the overall program.
Each event in an event-driven programming environment
must have a separate unit of code associated with it that
defines the actions taken when the event occurs. This
critical concept, called modularity, is fundamental to all
high-level programming languages. Modularization helps
eliminate duplicate code, improves program understand-
ability, and facilitates reusability (Harriger et al., 1999).
Visual Basic supports modularity through procedures and
functions. One or more data items can be transferred to
the module when it is executed. These data items are
calledparametersorarguments.
The act of transferring program execution to a mod-
ule is known as calling the module. The statement that
sends program execution to the module is the Call state-
ment. The module that contains the Call statement is the
Calling routine. The module that is executed is the Called
routine. Sending parameters to a module is called passing
parameters. Parameters are passed to a module by listing
them in parentheses immediately after the call.
Functions and procedures differ in how the program
behaves after the module executes. Procedures return
control to the calling point and sequential execution con-
tinues. Functions return control to the calling point, along
with a single data item. This returned data item replaces
the function in the calling statement and sequential exe-
cution continues.
Procedures use the Visual Basic keyword Call to exe-
cute a module. The Call keyword is followed by the mod-
ule’s name. The parameter list enclosed in parentheses
immediately follows the module name. Functions do not
use a specific Visual Basic keyword to initiate the call.
The function name, followed by the parameter list en-
closed in parentheses, is placed in a statement where a
constant or variable could be located. When the function
name is encountered, the module is executed. The value
returned by the function is substituted back into the call-
ing statement and the program continues to evaluate that
statement.Visual Basic Function Library
Visual Basic provides an extensive library of prewritten
functions. These functions handle common tasks such as
mathematical calculation and character string manipula-
tion. Unlike some languages, no special linking is needed
to make function libraries available to a Visual Basic pro-
gram. Library functions are called in the same manner as
user-defined functions.DATA ACCESS
Files
Visual Basic supports sequential and random access files,
although random access files are not widely used today.
Data manipulation needs that had been traditionally met
by random access files are now performed by database
systems. Currently, files are used to store relatively small
amounts of data that require simple processing. One of
the four sequential file formats supported by Visual Basic
can usually satisfy these modest requirements.
Visual Basic refers to files by numbers that are assigned
when the files are opened. File handling statements incor-
porate this file number identification system to differen-
tiate between open files. All file types supported by Visual
Basic use common open and close statements.Comma-Separated Values
Comma-Separated Values (CSV) is a commonly used file
format in which individual fields within the record are
separated by commas. String data are enclosed in dou-
ble quotation marks. CSV files contain variable-length
records; the number of characters in each record does
not have to be the same.Report–Record
Report–Record files are designed to be viewed, usually
in a printed form. Extra formatting data are included in
each record to enhance its appearance. Data fields are the
same length and align in vertical columns when viewed in
a report format. Pagination, page headers, page footers,
and column headers may also be included.Fixed Record-Length Type 1 and Type 2 Formats
Fixed Record-Length Type 1 files are compatible with files
used by programs written in the COBOL programming
language. Although little new development is being done
in COBOL, a large body of legacy COBOL still exists. All
field lengths are fixed, so all records are the same length.
Character and numeric data are stored in ANSI character
format (Harriger et al., 1999). Fixed Record-Length Type 2
files are similar to Type 1 files, with the exception that
numeric data are stored in binary format.Database and Data Access
Visual Basic’s data access features provide a convenient
way to create powerful front-end programs for database
access. These front-end programs insulate end users from
complex data management systems. Front-end programs
also provide a measure of data security, allowing con-
trol over the data accessed and the types of operations
allowed. Visual Basic 6.0 supports Microsoft’s Access