Skip navigation

Option Explicit and Variable Naming Conventions Make Life Easier

If you have programmed in Visual Basic, you probably know about Option Explicit. Option Explicit forces you to declare all variables before using them. If you don't declare Option Explicit, you can create nasty bugs by simply misspelling a variable name.

In the world of ASP there are two types of Option Explicit statements: client-side and server-side. The sample code contains an example of both types. The first Option Explicit, near the top, is for the server-side code, while the Option Explicit below the Client-Side Functions comment is for client-side code. It is important to use both types of Option Explicit in your ASP code.

There is only one explicit data type in VBScript: a variant. Since a variant can represent many different data types, you should keep track of what data type you put into the variant. Otherwise, it is all too easy to forget what type of data is really in the variable. Microsoft suggests you use a form of Hungarian notation for VBScript. For example, intQuantity represents a quantity that is an integer data type. You can find more information about the convention by searching for "VBScript Coding Convention" in the Visual InterDev online help.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish