Global Variables

E

e_hobsbawm

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top