The information in this article applies to:
SUMMARYWhen you have OLE objects that create OLE objects, these nested objects are destroyed (set equal to Nothing) when the parent object that created them is destroyed. MORE INFORMATION
Visual Basic releases all second-level objects (objects created by objects)
when the top level class is destroyed. This is essentially the same
behavior as an object variable going out of scope.
Class CTopLevel has the object members.
Class CSecondLevel has the object member.
In the Initialize event of CTopLevel, you set the ChildObject:
If the CTopLevel class is created and goes out of scope after the End Sub
in the following code:
a CSecondLevel object (ChildObject) is explicitly instantiated in the
CTopLevel_Initialize event, but implicitly destroyed when ParentObject goes
out of scope at the end of the Form_Click Sub procedure.
For objects that have not been destroyed when a Visual Basic application shuts down, Visual Basic does a two-pass cleanup on outstanding objects. Pass one releases all module level and static object references (classes and objects). Pass two releases the objects themselves. This allows parent and child objects to both shut down even though they may have module-level references to each other. Essentially, Visual Basic cleans up after itself very well. Additional query words: 4.00 vb4win vb4all
Keywords : |
Last Reviewed: January 25, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |