ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set array of objects to nothing (https://www.excelbanter.com/excel-programming/404697-set-array-objects-nothing.html)

Matthew Pfluger

Set array of objects to nothing
 
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

Peter T

Set array of objects to nothing
 
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

"Matthew Pfluger" wrote in
message ...
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




Matthew Pfluger

Set array of objects to nothing
 
Very good. Thanks!

"Peter T" wrote:

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

"Matthew Pfluger" wrote in
message ...
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






All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com