Does VBA have a garbage collector?

R

RyanH

I am starting to learn VB.NET. I know VB.NET has garbage collection so you
don't have to destroy the object in code. Does VBA have a form of garbage
collection or is it best to destroy the object manually in code?
 
P

Peter T

Yes. Typically I'm sure it's fine, if not better, to let VB's garbage
collection destroy objects naturally when they are about to fall out of
scope (eg procedure level objects as the procedure terminates).

You will still need to destroy static or module level objects when done.
Also there are certain scenarios that lead to circular references where a
particular object will need to be released first (probably a rare scenario
in VBA).

Some prefer to explicitly destroy all objects but that's more a matter of
style.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top