Quote:
Originally Posted by CoolBlue
The final point I would make is that there is no need to set local objects to nothing at the end of the sub. This is less efficient than letting VBARuntime do it for you, which it will. It also clutters up your code.
VBA uses reference counting to manage object life cycle, so if there are no references to an object then its deallocated from memory and this inherent process is much more efficient than setting objects to Nothing.
|
whatsup has already given valid reasons for setting object references to nothing. See post #7. Current VBA implementations by Microsoft may handle this correctly, but that has not always been so and there is no guarantee that it does so now for every conceivable object and that it will continue to do so into the future. Neither is there any guarantee that all non-Microsoft VBA implementations do so even now. Better to be safe than sorry. As for the clutter, methinks you protest too much - a single line of code can handle set multiple object references to nothing.