Setting variables to Nothing
reassigning it to refer to another object is fine. You don't have to set it
to nothing along the way/in between.
If you want to set it to nothing at the end, you can, but when it hits End
Sub, it will be set to nothing by VBA anyway. (if I recall correctly that it
is local to that procedure).
--
Regards,
Tom Ogilvy
"Matt Jensen" wrote in message
...
Thanks Tom
Pertaining to that checkbox naming code you helped me with yesterday:
snippet
dim cb as OLEObject
Set cb = ws.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
I reuse / redfine this cb variable/object several times in one procedure,
should I set it to nothing before each I use it again or just at the end
of
the proc?
Thanks
Matt
"Tom Ogilvy" wrote in message
...
integers can't be set to nothing. They are initialized to a value of
zero.
You shouldn't have to worry about any type of local variable because
they
go
out of scope and are destroyed when the code in which they are defined
stops
running.
No variables have a default value of Null, so you shouldn't use that.
Only objects can be set to Nothing
Dynamic arrays can be erased
--
Regards,
Tom Ogilvy
"Matt Jensen" wrote in message
...
As good programming practice, what of the possible variable types
should
be
set to nothing or null?
Can /should you set integers to nothing for example?
Thanks
Matt
|