What does 'Option Explicit' do anyway?
Printable View
What does 'Option Explicit' do anyway?
It makes it so you have to declare a variable to be able to use it...
VB's definition:
[/quote]
Used at module level to force explicit declaration of all variables in that module.
Syntax
Option Explicit
Remarks
If used, the Option Explicit statement must appear in a module before any statements that declare variables or define constants.
If you don't use the Option Explicit statement, all undeclared variables are of Variant type unless the default type is otherwise specified with a Deftype statement.
When you use the Option Explicit statement, you must explicitly declare all variables using the Dim, Private, Public, ReDim, or Static statements. If you attempt to use an undeclared variable name, an error occurs at compile time.
Tip Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid risking confusion in code where the scope of the variable is not clear.
[/quote]
And if i catch anyone not using Option Explicit i will personally come round to your house and slap you around till you swear on your life that you will always use it from that day on ;)
Not using Option Explicit is actually SOMETIMES helpful, for if you kept on forgetting to dim something, OE can give you a hard time.
Hey, why is Option Explicit so Popular? Why not Option Compare or Option Base?