次の方法で共有


Dim Statement

Declares variables and allocates storage space.

                      Dim varname[([subscripts])][, varname[([subscripts])]] . . .

Arguments

  • varname
    Name of the variable; follows standard variable naming conventions.

  • subscripts
    Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscripts argument uses the following syntax:

    upperbound [**,**upperbound] . . .

    The lower bound of an array is always zero.

Remarks

Variables declared with Dim at the script level are available to all procedures within the script. At the procedure level, variables are available only within the procedure.

You can also use the Dim statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array. If you try to redeclare a dimension for an array variable whose size was explicitly specified in a Dim statement, an error occurs.

For more information about using the Dim statement to create variables and arrays, see Visual Basic Scripting Edition (VBScript) Variables.

The following examples illustrate the use of the Dim statement:

                      Dim Names(9)       ' Declare an array with 10 elements.
Dim Names()        ' Declare a dynamic array.
Dim MyVar, MyNum   ' Declare two variables.

Requirements

Version 1

See Also

Reference

Private Statement

Public Statement

ReDim Statement

Set Statement

Array Function

IsArray Function

LBound Function

UBound Function

Private Statement

Public Statement

Erase Statement

Change History

Date

History

Reason

April 2009

Modified remarks.

Customer feedback.