Advanced Windows PowerShell Scripting Video Training

Advanced Windows PowerShell Scripting Video Training
Advanced Windows PowerShell Scripting Video Training

Sunday, June 28, 2009

What does "Option Explicit" mean in VBScript

The Option Explicit statement requires you to declare all variables before they can be used. You must have Option Explicit as the first executable statement in your script. After that, you must use Dim, Private, Public, or ReDim to declare all variables.

To novice scripters, this may seem more of a nussance then a helpful tool. Once you begin scripting longer and longer code, you will appricate it. It will help prevent you from accidentally decalring two variables of the same name. Without this statement, you could just declase a variable anywhere. Also, should you mistype the variable later on, an error message will help you locate the problem.

Option Explicit will help keep your code clean and organized.

No comments: