Chapter 3 ctd Section 3 2 EVENTS Three

  • Slides: 8
Download presentation
Chapter 3 (ctd) Section 3. 2 EVENTS

Chapter 3 (ctd) Section 3. 2 EVENTS

Three stages in the creation of a Visual Basic program: z. Create the interface

Three stages in the creation of a Visual Basic program: z. Create the interface yie, choose & create the objects z. Set the objects’ properties yuse the properties window of each object z. Create the code to respond to a user’s interaction with the objects z. Examples

Responding to events z We can write code to respond to user’s actions. z

Responding to events z We can write code to respond to user’s actions. z A user’s actions are called events. z Event-driven programs are ones in which specific groups (or modules) of statements are executed on the basis of what the user does. z In this section, we focus on statements that respond to a user’s actions by changing the properties of objects.

Basic features of an event procedure z. First, invoke the window of an object

Basic features of an event procedure z. First, invoke the window of an object by double-clicking on the object. z. Format: Private Sub Object. Name_Event () Private Sub Object. Name_Event() Visual here Visual. Basiccode goes here End Sub

Example from text, pp. 60 -64 z. Note the interface for the example: Object

Example from text, pp. 60 -64 z. Note the interface for the example: Object Walkthrough txt. Phrase cmd. Bold Property Caption Text Caption z. Let’s create it Setting Demonstration (blank) Make Phrase Bold

z. The text box txt. Phrase has 2 events written for it: ytxt. Phrase_Lost.

z. The text box txt. Phrase has 2 events written for it: ytxt. Phrase_Lost. Focus ytxt. Phrase_Got. Focus z. The command button cmd. Button has 1 event written for it: ycmd. Bold_Click

Lab Assignment (Lab 2) Due today! z. Create the forms, objects & events for

Lab Assignment (Lab 2) Due today! z. Create the forms, objects & events for p. 69: 38, 39, 40

Homework Assignment (HW 2) z. Due next Tuesday z. Page 70, #46, #47.

Homework Assignment (HW 2) z. Due next Tuesday z. Page 70, #46, #47.