|
-
Jul 15th, 2009, 04:41 AM
#5
Re: Correct procedure for declaring variables
 Originally Posted by ediblespread
EDIT (in response to Si's post):
Indeed, you did take your time - I'd already started replying!  .
It seems I've been fairly slow again! 
Thanks for answering. So, when you say primitives (actually, we, is String a primitive in VBA? Anyway, let's say basic) data types are automatically tidied up, how does that happen? When the subroutine ends/form unloads/program quits they're just reset to Nothing and killed automatically?
They are automatically tidied as needed when their scope expires (the subroutine ends/form unloads/program quits).
(Note, I use 'Dim' for basic data types too - or should I say the original code did, so I just continued - aka, Dim x as Integer. Is this wrong?)
Dim is used for all variables (or at least should be!).
The important point was the "as New", eg: Dim x as New y
...but using that isn't a good idea (there is an FAQ article which explains it), it is better to use a separate Set line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|