Have you ever forgotten to add code to set the MousePointer back to its default at the end of a procedureor function? This technique simplifies showing and resetting the MousePointer without adding code to theend of a procedure or function.When you create an object from a class, the Initialize event is generated. Any code in the event procedurefor that event then executes. This is the first code to execute for the object, before you set any properties orinvoke any methods. When the variable goes out of scope, all references to the object are released, theTerminate event is generated for the object, and any code in the Terminate event procedure for that object isexecuted:
Declare Sub Sleep Lib "kernel32" _ (ByVal dwMilliseconds As Long)' this is an example of a procedure that' uses the CHourGlass classPrivate Sub ProcessData() Dim MyHourGlass As CHourGlass Set MyHourGlass = New CHourGlass 'Add processing code here Sleep 5000 'This simulates the 'processing of data 'Resume processing code hereEnd Sub'Create a CHourGlass class with the 'following code:Private Sub Class_Initialize() 'Show HourGlass Screen.MousePointer = vbHourglassEnd SubPrivate Sub Class_Terminate() 'Restore MousePointer Screen.MousePointer = vbDefaultEnd Sub