Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default A question about Nothing

Hi

I understand what Nothing does:

Set MyObject = Nothing

But I don't understand the reason for it.
Especially at the end of a routine

Doesn't End Sub do the same thing?

Dave F.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default A question about Nothing

In an ideal world, The app should tidy up after itself rendering the:

Set Object = Nothing

as an excersize in futility, however some apps, mentioning no names (Access)
have bugs in them which may be avoided by setting object variables to
nothing at the end of the sub or function.

P


"Dave F" wrote in message
...
Hi

I understand what Nothing does:

Set MyObject = Nothing

But I don't understand the reason for it.
Especially at the end of a routine

Doesn't End Sub do the same thing?

Dave F.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default A question about Nothing

Hi Dave

No. "Set" allocates memory for something. Say you have an object X that uses 2Mb ram. Then
in theory it goes like this:

Set A as new X '2 Mb allocated for future use
Set B as new X 'and another 2
'.... do stuff with or without A and B, until
Set A as noting 'release A's 2 Mb for use elsewhere
Set B as nothing 'another 2

"In theory" because it doesn't always release, VBA or whatever program. In those cases you
have a "memory leak" and your Pc starts acting sluggish for no obvious or logical reason.
End Sub will or will not release memory, depending on wether the A variable is local or
not, and also on luck (memory leak II ). Anyway it's a very good coding habit to release
memory manually -we do have style after all ;-)
--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Dave F" wrote in message
...
Hi

I understand what Nothing does:

Set MyObject = Nothing

But I don't understand the reason for it.
Especially at the end of a routine

Doesn't End Sub do the same thing?

Dave F.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If Question Tango[_2_] Excel Discussion (Misc queries) 2 March 24th 10 02:35 PM
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM


All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"