Unlike standard modules, class modules can raise their own events. This is a very powerful feature of VBA, because it not only gives your code the ability to know what's going on inside the class instance, it provides the opportunity to take whatever actions you deem necessary based on those events.
Another very important benefit of using class events is that that you can keep User Interface (UI) functionality separate from the class implementation, making the class truly independent and reusable. You can then use your class in many places without worrying about specific UI implementation. This section focuses on getting your class to talk to the rest of your application through events.
Every class module has two built-in events that fire automatically: Initialize and Terminate. The Initialize event fires when the class instance is first created. You can use the Initialize event to set default property values and create references to other objects. The Terminate event fires before the object is destroyed, and is normally used to clean up local object references.
To define code for these events, select Class from the Object drop-down and then select the event from the Procedure drop-down, as shown in Figure 13-9.
The following example shows what the Initialize and Terminate events might ...