Set array of objects to nothing

  • Thread starter Thread starter Matthew Pfluger
  • Start date Start date
M

Matthew Pfluger

People have advised me to set object variables to nothing after they are no
longer needed:

Dim obj as Object
' do stuff
Set obj = Nothing

How do I set an array of objects to nothing?

Dim obj() as Object
ReDim obj(1 to Windows.Count)
' do stuff
' Set obj() = Nothing

Thanks,
Matthew Pfluger
 
You could loop through the array setting each item = Nothing or use 'Erase',
see help. They are not quite the same thing so use either method as
required.

If your array of objects is about to go out of scope it's not normally
necessary to explicitly release any object references it holds.

Regards,
Peter T
 
Very good. Thanks!

Peter T said:
You could loop through the array setting each item = Nothing or use 'Erase',
see help. They are not quite the same thing so use either method as
required.

If your array of objects is about to go out of scope it's not normally
necessary to explicitly release any object references it holds.

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

Back
Top