|
-
Jul 15th, 2009, 03:14 AM
#1
Thread Starter
New Member
[RESOLVED] Correct procedure for declaring variables
Hey guys. I was just wondering what exactly was the correct way to declare variables within a project. Obviously of course the best way to declare things is as private as you can, within procedures, then forms, then global if you absolutely must. However, I have a slight problem in that I have forms with (say) a dozen procedures which each have variables declared in them. If a certain error occurs, then I just want to quit to the desktop (my other thread in this forum deals with that particular problem), and therefore when that happens I need to wipe all my variables as I go (I think - if I unload all forms, I still need to set their variables to 'nothing', correct?). So, I plan to migrate all code nulling to my 'Terminate' event, to make sure all variables are killed. However, what happens if the application errors before a particular subroutine that declares variable 'foo' ever runs? Aka, I then try and "foo = Nothing", but foo doesn't exist.
So, should I a: declare all of my variables at form level, so they all exist in case the app errors and has to quit in a hurry, or b: use an On Error Resume Next in the Terminate event so that any non-initialised variables are just skipped over? (Resume Next... *shudder*)
Thanks,
Edibles
Last edited by ediblespread; Jul 15th, 2009 at 10:09 AM.
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
|