VBS TUTORIAL: VBScript statement-dim statement _vbs

Source: Internet
Author: User
Tags naming convention

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.