Learning about events

To find out which events are supported by a particular control, do the following:

1. Add a control to a UserForm.

2. Double-click the control to activate the code module for the UserForm. The VBE will insert an empty event handler procedure for the default event for the control.

3. Click the drop-down list in the upper-right corner of the module window, and you'll see a complete list of events for the control (see Figure 13-12).

□ Fl* [dh Vlt- |M« F«nuc Euhug rub Kad Im rtrfufe* kj*


Figure 13-12: The event list for a CheckBox control.

4. Select an event from the list, and the VBE will create an empty event handler procedure for you.

Note To find out specific details about an event, consult the Help system. The Help system also lists the events available for each control. When you locate an event for an object, make sure the Help system table of contents is displayed. Then you can see a list of all other events for the object.

Caution Event handler procedures incorporate the name of the object in the procedure's name.

Therefore, if you change the name of a control, you'll also need to make the appropriate changes to the control's event handler procedure(s). The name changes are not performed automatically! To make things easy on yourself, it's a good idea to provide names for your controls before you begin creating event handler procedures.

0 0


Post a comment