Lesson 4
Lesson 4
OBJECTIVES:
1. Acknowledge the anatomy of an Event handling Procedure
2. Demonstrate the parts of Object Properties Event Chart
3. Analyze the code editor window environment
4. Illustrate how codes works
ANATOMY OF AN EVENT HANDLING PROCEDURE
Event handling procedure contains the code that will be executed when a
particular event is triggered.
Reserve Word
Private Sub
Object Name
Event Type
cmddisplay _ Click ( )
Reserve Word
Instructions to be
executed
lblgreetings
gpd
cmddisplay
1|Page
Each Visual Basic event has a subprogram associated with it. This is why
Visual Basic automatically includes the Private Sub and End Sub commands in your
code.
The name of the control (in this case cmddisplay) and the event (in this
case click) will be joined together to form the subprogram name. This name
follows the Sub statement.
OPE Chart (Objects Properties Event chart)
The graphical representation in describing the objects used and the
properties and events associated to the objects.
frmbati(batiFORM)
The main form of the
program.
Maxbutton
is
set
to
False.
Unloaded when close or
x button is clicked.
cmddisplay (COMMAND
lblgreetings (LABEL)
Display
the
Welcome
to
message
Visual
Basic.
Alignment is center.
Font size is 24 and Font
is MS Sans Serif. Font
style
is bold.
Writing
Code
2|Page
BUTTON)
cmdclose (COMMAND
BUTTON)
is
click,
message
is
change
to
Character is D.
Display.
Mnemonic
clicked.
Access
Character is C.
Access
The Code Editor window is where you write Visual Basic code for your
application. Code consists of language statements, constants, and declarations.
Using the Code Editor window, you can quickly view and edit any of the
code in your application.
To open the Code window
Double-click the form or control for which you choose to write code or
from the Project Explorer window, select the name of a form or module, and
choose the View Code button.
You can choose to display all procedures in the same Code window, or display a
single procedure at a time.
3|Page
2. Procedure list box Lists the procedures, or events, for an object. The box
displays the name of the selected procedure in this case, Click. Choose the
arrow to the right of the box to display all the procedures for the object.
4|Page
Cmdclear
(commandbutton)
Clear
lblomsc (label)
the
Caption
of
Cmdshow
(commandbutton)
Caption is Clear.
Cmdclose
lblomsc
(commandbutton)
Mindoro
State College
Font is Ms Sans Serif,
Fontsize is 24, Forecolor is
Blue. The Alignment is
Center.
5|Page
to
Occidental