Broadly speaking, programs can be either procedure driven
. In a procedure-driven program,
program flow is predefined. A classic example is a console
application: program flow begins at the program entry point (in the
case of a .NET console application, it begins with the
routine) and proceeds along a predictable path until it reaches
program termination. In an event-driven program, on the other hand,
program flow is not predetermined and is instead controlled by
external events (i.e., by the program’s interaction
with the user and the system), and possibly by internal events as
From the perspective of program structure, the difference between
procedure-driven and event-driven programs is less sharp than is
usually thought. Both rely on a procedure as an entry point, which in
turn can call other functions and subroutines that are visible to it.
The major difference is that a procedure-driven program has a single
entry point, whereas an event-driven program has multiple entry
points. For event-driven programs, these entry points (in addition to
Main procedure) are event handlers
, which are invoked automatically by
the .NET Common Language Runtime in response to an event within the
code itself or in its environment.
Therefore, regardless of whether an application is procedure driven or event driven, Visual Basic code can be divided into three main categories:
For procedural applications, this ...