Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing an object - need to destroy it as well? 1

Status
Not open for further replies.

AlexNeil

Programmer
Jun 4, 2001
49
GB

When I remove an object from a Collection, is that object destroyed? Or should I first set the object to nothing and then remove it?

thanks,
Alex
 
I believe that when you remove an object from a collection its link to the collection is removed/destroyed but the object still exists. If you want to remove/destroy the object entirely and free up the memory it uses then set the object equal to nothing after it has been removed from the collection.
Thanks and Good Luck!

zemp
 
The object is destroyed when there are no more references to it. You can not "set" an object to Nothing. You can set a variable that contains an object reference to Nothing. Therefore if you use the Remove method to take a reference to an object out of a Collection then the Remove method sets the Collection's reference to that object to Nothing and if that was the last reference to that object then the object will be destroyed after its Class_Terminate event is triggered. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top