Name
Private Statement
Syntax
Privatevarname
[([subscripts
])] [,varname
[([subscripts
])] . ..
-
varname
Use: Required
Variant Subtype: Any
The name of the variable, following Visual Basic naming conventions.
-
subscripts
Use: Optional
Variant Subtype: Integer or Long
Denotes
varname
as an array and optionally specifies the number and extent of array dimensions.
Description
Used in a script or in a class to declare a private or local variable and allocate the relevant storage space in memory.
Rules at a Glance
A
Private
variable’s scope is limited to the script in which it’s created for script-level variables and to the class in which it is declared for class-level variables. Elsewhere, thePrivate
keyword generates an error.varname
follows standard VB naming conventions. It must begin with an alphabetic character, can’t contain embedded periods or spaces, can’t be the same as a VBScript reserved word, must be shorter than 255 characters, and must be unique within its scope.The
subscripts
argument has the following syntax:upperbound
[,upperbound
]...For example:
Private strNames(10)
defines an array of 11 elements (an array whose lower bound is and whose upper bound is 10). Similarly:
Private lngPrices(10, 10)
defines a two-dimensional array of eleven elements in each dimension.
Using the
subscripts
argument, you can declare up to 60 multiple dimensions for the array.If the
subscripts
argument isn’t used (i.e., the variable name is followed by empty parentheses), the array is declared dynamic. You ...
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.