Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

VBScript Private Statement

Used at script level to declare private variables and allocate storage space.

Syntax: VBScript Private Statement

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

Arguments: VBScript Private Statement

varname

The name of the variable; follows standard variable naming conventions.

subscripts

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

upper [, upper] . . .

The lower bound of an array is always zero.

Remarks: VBScript Private Statement

Private variables are available only to the script in which they are declared.

A variable that refers to an object must be assigned an existing object using the Set statement before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing.

You can also use the Private 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 Private, Public, or Dim statement, an error occurs.

When variables are initialized, a numeric variable is initialized to 0 and a string is initialized to a zero-length string ("").

The following example illustrates use of the Option Explicit statement:

Option Explicit   ' Force explicit variable declaration.

Dim MyVar   ' Declare variable.

MyInt = 10   ' Undeclared variable generates error.

MyVar = 10   ' Declared variable does not generate error.

Tip

When you use the Private statement in a procedure, you generally put the Private statement at the beginning of the procedure.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.