VBS TUTORIAL: VBScript statement-public statement _vbs

Source: Internet
Author: User

Public statement

Define public variables and allocate storage space. Define a private variable in the Class block.

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

Parameters

VarName

The name of the variable, followed by the standard variable naming convention.

subscripts

The number of dimensions of the array variable; You can declare up to 60-d arrays. The subscripts parameter uses the following syntax:

Upper [,Upper] ...

The lower bound of an array is always 0.

Description

The public statement variable can be used for all procedures in all scripts.

Before you can use a variable that references an object, you must assign an existing object to the variable with the Set statement. The declared object variable is initialized to Empty before assigning the value.

You can also declare a dynamic array by using the public 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 declare the dimension of an array variable, and the size of this array variable has been explicitly specified in Private, public, or Dim statements.

The following example illustrates how to use the public statement:

    public  mynumber    ' public Variant variable. Public  MyArray (9)     ' public array variable.    ' multiple public declarations of Variant Variables.   public  MyNumber, MyVar, yournumber     

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.