73
VBScript Reference Manual
InduSoft Web Studio
174
InduSoft, Ltd.
Const
Description
Declares constants for use in place of literal values
Usage
[Public | Private] Const constname = expression
ssion
Arguments
Public
Optional. Keyword used at script level to declare constants that are available to all
procedures in all scripts. Not allowed in procedures.
Private
Optional. Keyword used at script level to declare constants that are available only within the
script where the declaration is made. Not allowed in procedures.
constname
Required. Name of the constant; follows standard variable naming conventions.
expression
Required. Literal or other constant, or any combination that includes all arithmetic or logical
operators except Is.
Remarks
Constants are public by default. Within procedures, constants are always private; their visibility
can't be changed. Within a script, the default visibility of a script-level constant can be changed
using the Private keyword.
To combine several constant declarations on the same line, separate each constant assignment
with a comma. When constant declarations are combined in this way, the Public or Private
keyword, if used, applies to all of them.
You can't use variables, user-defined functions, or intrinsic VBScript functions (such as Chr) in
n
constant declarations. By definition, they can't be constants. You also can't create a constant
from any expression that involves an operator, that is, only simple constants are allowed.
Constants declared in a Sub or Function procedure are local to that procedure. A constant
t
declared outside a procedure is defined throughout the script in which it is declared. You can use
constants anywhere you can use an expression.
Example
Const MyVar = 459
'Constants are Public by default.
Private Const MyString = "HELP"
'Declare Private constant.
Const MyStr = "Hello", MyNumber = 3.4567 ‘Declare multiple constants on same line.
Dim
Description
Declares variables and allocates storage space
Usage
Dim varname[([subscripts])][, varname
ame
[([subscripts])]] . . .
Arguments
varname
Name of the variable, following 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: Upper[,upper]…
The lower bound of an array is always zero.
Remarks
Variables declared with the Dim statement at the script level are available to all procedures within
the script. Variables declared within a procedure are available only within the procedure.
A Dim statement with empty parentheses declares a dynamic array, which can be
defined later within a procedure using the ReDim statement.
Returns
N/A
Example
Dim counter
‘ Declare a variable
Dim counter1, counter2
‘ Declares two variables
Dim item(9)
‘ Declares an array with 10 elements
Dim item()
‘ Declares a dynamic array