Let's say I'm trying to access an ActiveX .dll using this code
Dim obj as Object
Set obj = CreateObject("Project1.Class1")
obj.HelloWorld
now how can I properly free this object?
Set obj = Nothing
is not doing it.
Unload obj
cannot be done
IIRC, VB6 automatically unloads objects when the form they're on (or the sub/function they're in) are unloaded (or completed).
Well I have the object loaded in a public variable to do things with it throughout the program until I need to unload it, and I just want to unload that object, not the entire program.
Ah... I'm not sure you can do that... Try creating a form that acts as the holder of the object, and then Loading/Unloading the form when you want to load/unload the object. Remember to Set Form1 = Nothing when you unload.
Quote from: RealityRipple on September 22, 2006, 09:51 PM
Ah... I'm not sure you can do that... Try creating a form that acts as the holder of the object, and then Loading/Unloading the form when you want to load/unload the object. Remember to Set Form1 = Nothing when you unload.
i'd rather not unload it than do something so lame.
I have a great quote of some newb saying someone was an idiot because of a memory leak in their application, and that they didn't know how to unload objects when finishing the use of them. When infact there was no memory leak involved in the program.
Oh wait...that newb was.... ---THIS ARROW POINTS UP---^
Set obj = Nothing has worked for me in the past.. where have you seen a problem with it?
I solved this thanks.