To cause a control to react
in a certain way to user or system activity,
you must put code in the appropriate event procedure
of the control. The VB IDE automatically provides
event procedure stubs for a control as soon
as you define an instance of a control by placing
its icon on the form designer surface.
NOTE: Events
Versus Event Procedures You will often
hear VB programmers loosely refer to writing
code in "events." Technically, this
is not correct. You don't write code in
events; you write code in event procedures.
When you double-click the control
instance, you call up a Code Window for one
of the control's event procedures, as
seen in Figure 3.15. Which event procedure you
see first depends on one of two possibilities:

FIGURE 3.15 - Editing an event procedure in the Code window
-
If you haven't yet
done anything with the control's event
procedures, you first see the user interface
Default event procedure, that is, the procedure
for the event that's considered to be
the most important event for the control.
-
If you've already
written some event procedure code, then you
call up the first event procedure in alphabetical
order for which you've already provided
some code.
The default event procedures for the three most basic controls are:
-
The Click event for the
CommandButton.
-
The Change event for the
TextBox.
-
The Click event for the
Label control.
It's a very good idea
to hold off writing any event procedure code
until you've re-named all controls appropriately.
We discuss this idea further in the following
section.
NOTE: Events Versus Event Procedures You will often hear VB
programmers loosely refer to writing code in "events." Technically, this is not
correct. You don't write code in events; you write code in event procedures.