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 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 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 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. 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 p. 69: 38, 39, 40
Homework Assignment (HW 2) z. Due next Tuesday z. Page 70, #46, #47.