Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 06-16-2014, 06:43 PM
macropod's Avatar
macropod macropod is offline Slow "comparison/replace" script Windows 7 32bit Slow "comparison/replace" script Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by CoolBlue View Post
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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd "script code" in a downloaded .doc file CNBarnes Word 2 10-18-2012 02:07 AM
Slow "comparison/replace" script replace data from variable with "sub and super script" from excel to word by vba krishnaoptif Word VBA 9 06-22-2012 05:08 AM
Slow "comparison/replace" script How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
Rules and Alerts: "run a script"? discountvc Outlook 0 06-15-2010 07:36 AM
An "error has occurred in the script on this page" decann Outlook 8 09-03-2009 08:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft