VB tutorial > lesson 5 VBScript constants
What is a constant?
A constant is a meaningful name used in place of a number or string, and its value never changes. VBScript defines many intrinsic constants. For more information, see the VBScript language reference.
You can use const statements to create user-defined constants in VBScript. Use const statement to create string or numeric constants whose names have certain meanings and assign them original values. For example:
Const mystring = “this is a string.”
Const MyAge = 49
Notice that the string text is enclosed between two quotation marks (“”). This is the most obvious way to distinguish between string constants and numeric constants. Date text and time text are contained between two pound signs (#). For example:
Const CutoffDate = #6-1-97#
It is best to use a naming scheme to distinguish between constants and variables. This avoids reassigning constants when running a script. For example, you can use “VB” or “con” as the prefix of constant names, or capitalize all letters of constant names. Separating constants from variables can avoid confusion when developing complex scripts.