-
I'm making a program that does various things in a complicated way and there's a a bug :(
I'm using a lot of modules which get used, then left alone for a long time, some of these modules use class modules, but a lot of the time instances of these classes are left open after the module is finished with.
I don't want to change the whole structure of my program to close them but I do want them closed.
Can I get a collection or something of all instances of a certain class so I can just loop through and close them.
-
If you implement a common inferface with all of the classes, shouldn't you be able to do just that?
-
I don't understand. I need to be able to close all instances of a class, how will making the the interfaces of different classes the same help?
-
You would have to close them manually
If you have several objects declared in different modules, i think you could make all modules containg two methods, one that inits all objects and one that unloads them..
For instance:
Code:
Module1.InitObjs
Module2.InitObjs
'Do stuff
Module1.TerminateObjs
Module2.TerminateObjs
Then you have in the modules
Code:
Public object1 as class1,object2 as class1
sub InitObjs
Set object1=new class1
set object2=new class2
end sub
sub TerminateObjs
Set object1=nothing
set object2=nothing
end sub
-
That's exactly what I wanted to avoid
-
Well, you can't, but there's another way
you can load all objects under one main object, and then you unload the main object, which will terminate all subobjects