Vbscript| Constants | tutorials
What is a constant?
A constant is a name that has a meaning, used in place of a number or string, and its value never changes. VBScript defines a number of intrinsic constants. For more information, see the VBScript Language Reference.
Creating constants
You can use the Const statement to create user-defined constants in VBScript. Use the Const statement to create a string or numeric constant with a certain meaning to the name, and to assign them a literal value. For example:
Const MyString = "This is a string. "
Const Myage = 49
Note that the string literal is contained between two quotes (""). This is the most obvious way to differentiate between string and numeric constants. The date text and time text are contained between two pound numbers (#). For example:
Const cutoffdate = #6 -1-97#
It is best to use a naming scheme to differentiate between constants and variables. This avoids the value being assigned to the constant when the Script is run. For example, you can use either "VB" or "con" as the prefix for a constant name, or capitalize all the letters of a constant number. Separating constants from variables can avoid clutter when developing complex Script.