Const statement
The Declaration is used to replace the constant of the text value.
[Public | private]ConstConstname = expression
Parameters
Public
Optional. This keyword is used to declare constants that can be used for all processes in all scripts at the script level. It cannot be used in the process.
Private
Optional. This keyword is used to declare constants that can only be used in the script where the declaration is located. It cannot be used in the process.
Constname
Required. Constant name, according to standard variable naming conventions.
Expression
Required. Text or other constants, or including DivisionIsAny combination of all Arithmetic Operators and logical operators.
Description
By default, constants are public. Constants in the process are always proprietary, and their visibility cannot be changed. Script, availablePrivateKeyword to change the default value of the script-level constant visibility.
Several constants must be declared in the same row. Each constant can be assigned a value with commas. If the constant is declared using this methodPublicOrPrivateKeyword, the keyword is valid for all constants in the row.
Variable, user-defined function, or VBScript internal function (suchCHR). By definition, they cannot be constants. In addition, you cannot create constants from expressions that contain operators. That is, you can only use simple constants. InSubOrFunctionThe constant declared in the process is the local constant of the process. The constant declared outside the process is the global constant in the script where the declaration is located. Constants can be used wherever expressions are used. BelowCodeExamplesConstStatement:
ConstMyvar = 459
'
Constant:
Public.PrivateConstMystring = "help"
'
Defines the private constant.ConstMystr = "hello", mynumber = 3.4567.
'
Multiple constants are defined on one row.
Note:The constant can be supported by the script and can be easily modified. Unlike variables, constants cannot be accidentally modified when a script is running.