### Event Example 2: Modify Object Properties on Triggered Event

This exercise follows the above exercise, you should have completed it first. This example also uses the Form Editor.

Suppose you want to modify the properties of another object (say the text in a text object) when the button has been clicked.

1. Select View | Form Editor to access the Form Editor.

2. Switch back to Edit Mode (press CTRL + E).

3. Create a new text object.

4. Open the text object’s properties (select and then right mouse click).

5. Make sure that the text item’s Object Code property reads “Text1”. The Object Code property is the name that is used to refer to that object from BASIC code.

6. If not expanded, click on the + sign next to the Events section to expand the list.

7. double-click on the EventInitialize handler function. The VBS Mini-Editor opens.

8. Add the following code to the EventInitialize function:
   Set This = Text1

9. Press the ENTER key to get to a new line. On the next line type this code:
   This.Text = “The button has not yet been clicked”

10. Click the Ok button to close the editor.

11. Once the object Text1 has been set up as described, open the property sheet for the button object added in the prior exercise.

12. Click the Events tab.

13. double-click on the EventClick function.

14. Replace the basic code you added in the previous example with the following two lines:
    Line 1: MsgBox “I’ve been clicked, and am about to modify Text1’s text”
    Line 2: Text1.Text = “The button was clicked!!!”

15. Click the OK button to close the VBS Mini-Editor.

16. Close the Property Sheet.

17. Switch to Run Mode (press CTRL + E). The code you added to Text1’s EventInitialize function will set Text1 to initially read “The button has not yet been clicked”.

18. Now try clicking on the button. The “I’ve been clicked, and am about to modify Text1’s text” message should appear. As soon as you close the message box, Text1’s text should be modified to read “The button was clicked!!!”.

This example illustrates how the properties of any object in a form may be accessed from Basic code via the ObjectCode.property_name syntax.