Constants
Constants are identifiers that represent literals or constant expressions that can not be changed after they are defined.
For example, Const PI = 3.1415926535897932 will always mean that the identifier PI refers to the number 3.1415926535897932. The identifier PI can be used instead of repeating the full number in source.
Built-in constants include the boolean data type values true and false.
A constant definition differs from a variable definition. Variables hold values that can be changed.
Examples:
Declare Sub PrintConstants ()
Const FirstNumber = 1
Const SecondNumber = 2
Const FirstString = "First string."
Const FirstBoolean = False
Const SecondBoolean = True
Print FirstNumber, SecondNumber 'This will print 1 2
Print FirstString 'This will print First string.
Print FirstBoolean, SecondBoolean 'This will print false true
Print
PrintConstants ()
Sub PrintConstants ()
Print FirstNumber, SecondNumber 'This will also print 1 2
Print FirstString 'This will also print First string.
Print FirstBoolean, SecondBoolean 'This will also print false true
End Sub
Const FirstNumber = 1
Const SecondNumber = 2
Const FirstString = "First string."
Const FirstBoolean = False
Const SecondBoolean = True
Print FirstNumber, SecondNumber 'This will print 1 2
Print FirstString 'This will print First string.
Print FirstBoolean, SecondBoolean 'This will print false true
PrintConstants ()
Sub PrintConstants ()
Print FirstNumber, SecondNumber 'This will also print 1 2
Print FirstString 'This will also print First string.
Print FirstBoolean, SecondBoolean 'This will also print false true
End Sub
See also:
Back to Programmer's Guide