Const Statement

Declares constants for use in place of literal values.

Syntax

[Public] Const constname = expression

Arguments:

  • Public: Optional. Keyword used at script level to declare constants that are available to all procedures in scripts. 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.

The following example illustrates the use of the Const statement:

Example 1:


Const MyVar = 459
Const MyString = "HELP"
Const MyStr = "Hello", MyNumber = 3.4567   ' Declare multiple constants on same line.

Note:

Constants can make your scripts self-documenting and easy to modify. Unlike variables, constants cannot be inadvertently changed while your script is running.