I have been occasionally noticing while operating in Debug \ Stepped Execution mode that when execution encounters creation of a custom class object:
That the code execution passes through both the class constructor and destructor before continuing beyond the Set statement which was creating the object. In other words I see all of this code execute:
The class appears to work properly, is able to use the m_PrivateCollection Collection object properly.
Why does the class destructor run directly following the constructor?
Code:
Set ObjAdminPickListStandardAQEItems = New clsObjAdminPickListStandardAQEItems
Code:
Private Sub Class_Initialize()
On Error GoTo Err_Initialize
Set m_PrivateCollection = New Collection
Exit_Initialize:
Exit Sub
Err_Initialize:
Call errorhandler_MsgBox("Class: clsObjAdminPickListStandardAQEItems, Subroutine: Initialize()")
Resume Exit_Initialize
End Sub
Private Sub Class_Terminate()
On Error GoTo Err_Terminate
Set m_PrivateCollection = Nothing
Exit_Terminate:
Exit Sub
Err_Terminate:
Call errorhandler_MsgBox("Class: clsObjAdminPickListStandardAQEItems, Subroutine: Terminate()")
Resume Exit_Terminate
End Sub
Why does the class destructor run directly following the constructor?