0% found this document useful (0 votes)
47 views5 pages

Lesson 4

1. The document discusses event handling procedures in visual basic, including the anatomy of an event procedure which contains code executed when an event is triggered. 2. It also examines object property event charts which graphically show objects, properties, and events, and the code editor window where visual basic code is written. 3. Key aspects of working with code are outlined, such as writing code in response to button clicks that changes label text, fonts, and closes the program.

Uploaded by

api-287763322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views5 pages

Lesson 4

1. The document discusses event handling procedures in visual basic, including the anatomy of an event procedure which contains code executed when an event is triggered. 2. It also examines object property event charts which graphically show objects, properties, and events, and the code editor window where visual basic code is written. 3. Key aspects of working with code are outlined, such as writing code in response to button clicks that changes label text, fonts, and closes the program.

Uploaded by

api-287763322
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson 4

Working with Event Procedure and Codes


Event Handling Procedures
Object Properties Event chart
Code Elements
Source Codes

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 ( )

lblgreetings.Caption = "Welcome to Visual Basic"


End Sub

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

When the Display button

BUTTON)

is

Ends the program when

click,

message

Welcome to Visual Basic


is displayed.
Caption

is

change

to

Character is D.

Caption is set to Close.


Mnemonic

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.

The Code Editor window

You can choose to display all procedures in the same Code window, or display a
single procedure at a time.

3|Page

The Code Window Elements:


1. Object list box Displays the name of the selected object. Click the arrow to
the right of the list box to display a list of all objects associated with the form.

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

WORKING WITH CODES


Source code, often referred to as simply the "source" of a program, contains
variable declarations, instructions, functions, loops, and other statements that tell
the program how to function. Programmers may also add comments to their
source code that explain sections of the code.
EXAMPLE:
Display the message Occidental Mindoro State College when the Show
button is clicked.
frmOMSC (Form)
Changes the lblomsc Font to
Ms Sans Serif, Fontsize to
24, Forecolor to Blue. The
Alignment to Center.

Cmdclear
(commandbutton)
Clear
lblomsc (label)

the

Caption

of

lblomsc when clicked.

Cmdshow
(commandbutton)

Caption is Clear.

Changes the Caption of

Cmdclose

lblomsc

(commandbutton)

Used to display the string


Occidental

Mindoro

State College
Font is Ms Sans Serif,
Fontsize is 24, Forecolor is
Blue. The Alignment is
Center.

5|Page

to

Occidental

Mindoro State College


when clicked.
Caption is Show.

Terminates the program


when clicked.
Caption is Close.

You might also like