The Internet Encyclopedia (Volume 3)

(coco) #1

P1: IML


Owen WL040/Bidgolio-Vol I WL040-Sample.cls June 20, 2003 17:37 Char Count= 0


610 VISUALBASIC

and methods together into a single unit. This allows a user
to access the data through the available methods with no
knowledge of how the data are stored or how the methods
perform their tasks. The user simply executes a method
that performs some desired action on the data. Objects are
further defined by properties, which tell something about
the object. The color, the size, and the font used are all
examples of properties an object might have. The specific
properties associated with an object depend on the object
itself and the information needed to define its look, feel,
and behavior. Visual Basic 6.0 and earlier versions are not
true object-oriented programming languages (Bradley &
Millspaugh, 1998; Harriger et al., 1999; Shelly et al., 1999).
A working knowledge of inheritance and polymor-
phism are crucial to an understanding of objects in the
programming environment. Objects are part of object
classes, which are plans or specifications used to cre-
ate multiple objects with the same attributes and behav-
iors. A specific object of a given class is called an in-
stance of that class. The instance automatically contains
all the attributes and behaviors defined in the class. New
object classes can be created by modifying existing ob-
ject classes. Such a new object class is called a subclass.
Through a mechanism called inheritance, the new sub-
class is defined in terms of the difference between itself
and the object class from which it originated (Shelly et al.,
1999).
Polymorphism is the ability of a method to perform dif-
ferent tasks, depending on the object it is associated with.
Polymorphism allows instructions for object manipula-
tion to be given in more general terms. For example, a
method called Start can represent a general activity that
can be associated with a variety of objects such as auto-
mobiles or microwave ovens. Rather than provide specific,
detailed instruction on how to start either a car or a mi-
crowave oven, the user simply initiates the Start method.
The Start method exists in both objects, but it performs a
very different activity on the car than on the microwave.
The user does not need to know anything about these
activities or how they differ. The Start method will per-
form the appropriate start actions on the object (Lahotka,
2002).
Only Visual Basic.NET is a true object language. Ver-
sions prior to .NET use an inheritance mechanism that
does not conform to the strict definition of object inheri-
tance.

Visual Programming and Visual Basic
Whether or not Visual Basic is a visual programming lan-
guage depends on the definition of visual programming
applied, visual environment or visual syntax. An appli-
cation development system that contains graphical tools
that aid in creating and manipulating a program written
in a text-based language is called a visual environment.
Visual Basic is a visual environment programming lan-
guage. Programs are created by selecting common Win-
dows controls from a graphical list called the Tool Box.
The mouse is used to select a control from the list and
place it on the form. Once on the form, controls can be
moved, resized, and aligned using the mouse. The com-
plete user interface for a program can be created and

refined in the Visual Basic environment without typing
a single character on the keyboard (Harriger et al., 1999).
An application development system that expresses syn-
tax (or grammar) in a graphical manner via pictures,
diagrams, and symbols is called a visual syntax environ-
ment. A complete program can be created with no key-
board text entry. The diagrams, symbols, and pictures em-
ployed show containment and relationships between the
various elements of the program and how these elements
should be manipulated. Visual Basic does not fit these cri-
teria. Most program statements in Visual Basic must be
entered as text via the keyboard. As statements are entered
the development environment will provide some level of
context-sensitive help. Pop-up message windows provide
syntax and format assistance specific to the language el-
ement. Therefore, the more restrictive visual syntax defi-
nition of visual programming cannot be applied to Visual
Basic (Harriger et al., 1999).

Event-Driven Programming in Visual Basic
Objects have events associated with them. These events
are usually actions that can be performed on the objects
by an outside source, such as the user. Examples of events
in a Windows environment include clicking a mouse but-
ton, keyboard input, moving the mouse, changing the fo-
cus to a different control, and dragging and dropping. The
object’s response to a given event is expressed as a series
of programming language statements that are contained
in a method called an event procedure. This event proce-
dure determines how the object will respond to the event.
A large part of the programming task is identifying the
events to which the program must respond and coding
those responses (Harriger et al., 1999).
Events have ushered in a new approach to program-
ming. Prior to graphical user interfaces (GUIs), all pro-
gramming was procedural in nature. The program deter-
mined what actions would be taken and their order. With
the GUI, the events and the order in which they are per-
formed dictate the actions that occur within the program.
The ability of the user to perform multiple events on mul-
tiple objects in any sequence is completely inconsistent
with procedural design (McKeown, 1999). Programs must
now be designed without restrictions on the sequence or
timing of the user’s interaction. The emphasis has shifted
from controlling user interaction to reacting to the user
interaction. This subtle change has created a completely
new event driven approach to application design and de-
velopment.

THE VISUAL BASIC USER INTERFACE
Getting Started in the Visual Basic
Development Environment
Visual Basic offers a completely integrated development
environment (IDE) from which a programmer can design
the form, enter code, and test, debug, and save a program.
The user does not have to leave the integrated develop-
ment environment. This ability to move quickly between
the development and testing stages promotes faster and
more efficient application development. Once develop-
ment is complete, the program can be saved and compiled
Free download pdf