View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] e_hobsbawm@hotmail.com is offline
external usenet poster
 
Posts: 7
Default Global Variables

As in other languages, I guess it's considered good form to free
allocated variables.

I have a global variable of tyoe myObjectClasss, which I declare in the

module header like this:


Option Explicit
dim myObject as myObjectClass


I have made a sub updateMyObject which looks like this


Sub updateMyObject(a as integer)


If myObject = Nothing Then
set myObject = new myObjectClass
end if


myObject.initialize(a)


end Sub


I then have a lot of subs and functions that use myObject. It seems to
work fine.


However, Excel always crash when I shut it down. I am slightly worried
that it is because I never free myObject.


Would it be better if I set the variable in workbook_open and set it to

nothing in workbook_close?


Best Regards
Eric