Option Explicit Statement
Implemented in version 1.0
statement allows you to explicitly declare one or more new variables and to allocate storage (memory) space.
While you do not have to use
to create new variables in VBScript, the wise programmer prefers to use
. In fact, many programmer purposely include the
statement in all of their VBScript programs which mandates that all variables be explicitly declared.
<% Dim myvariable %>
<% Dim OneVar, TwoVar, ThreeVar, FourVar, MoreVar, EvenMoreVar %>
can also be used to create static (fixed) and dynamic arrays.
A static array has the number of elements declared by the
statement. However, you must remember that the elements in an array are numbered starting at zero. Consider the following
declaration. It creates a static array containing six elements that are numbered 0, 1, 2, 3, 4 and 5.
<% Dim SixElementArray(5) %>
A dynamic array is declared using empty parentheses. At a later point in your program, you can use the
statement to declare the number of dimensions and elements. In fact, you can redeclare a dynamic array as many times as you desire.
Arrays can also have up to sixty dimensions. For example, the following code creates a three dimensional array. The first dimension has 23 elements, the second dimension has 15 elements and the third dimension has 201 elements. Therefore, there are a total of 23x15x201 = 69345 elements in this array.
The number of dimensions that you can create is limited by the available memory. If you exceed the available memory while declaring an array, you will get an error message.
<% Dim ThreeDimensionArray(22, 14, 200) %>
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.