|
-
Apr 7th, 2007, 08:43 PM
#2
Re: Classic VB - What is Option Explicit, and why should I use it?
The reason for this is that I mis-spelt the variable name (MyVariable = MyVaraible - 2), so VB being 'kind' creates a new variable (which has a default value of 0), and uses it in the calculation
May I clarify few things please...
When variable declaration isn't required then for each new name space VB will allocate memory as it would for Variant type - this could actually mean major performance issue.
Initially new variable is Empty due to being variant. However since VB evaluates each expression before it executes one it will assing ZERO to a variable if it is part of mathematical equation.
The bottom line: regardless of whether or not Option Explicit is used (it should be in my opinion) it's always a great idea to explicitely declare the variable.
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
|