Dim statement
Declare variables and allocate storage space.
Dim varname[([subscripts])][, varname[([subscripts])]] . . .
Parameters
VarName
The name of the variable, conforming to the standard variable naming convention.
subscripts
The number of dimensions of an array variable that can declare up to 60-d arrays. The subscripts parameter uses the following syntax:
Upperbound [, Upperbound] ...
The lower bound of an array is always 0.
Description
Script-level variables declared with Dim are available for all procedures in the script, and process-level variables can only be used in procedures.
You can also declare a dynamic array by using the Dim statement with empty parentheses. After declaring a dynamic array, you can use the ReDim statement within the procedure to define the dimensions and elements of the array. An error occurs if you attempt to redefine an array that has already explicitly specified a dimension in the Dim statement.
Note When you use the Dim Statement in a procedure, you usually place the Dim Statement at the beginning of the procedure.
The following example illustrates how to use the Dim statement:
Dim Names(9) '
Declares an
array that has an element. Dim Names() '
declares a dynamic array. Dim MyVar, MyNum '
declare two variables.