Creating Constants
You can create user-defined
constants in BSL using the Const statement. Using the Const
statement, you can create string or numeric constants with meaningful names and
assign them literal values.
For example:
Const MyString = "This is my string."
Const MyAge = 49
Note:
The string literal is enclosed in quotation marks ("") . Quotation marks are the most obvious way to differentiate string values from numeric values.The following examples illustrates the use of the creating constants:
Example 1:
Const MyString = "This is my string."
'Defines a string constant.
Example 2:
Const MyAge = 49
'Defines a numeric constant.
Example 3:
Const Pi =
3.14159, E = 2.71828, Gravity = 9.81 'Defines multiple numeric
constants.
Example 4:
Const Greeting = "Hello,"
Const Name = "Alice"
Dim WelcomeMessage
WelcomeMessage = Greeting & Name 'Combines string constants.
'WelcomeMessage 'has string value: Hello, Alice