Const

From Real Software Documentation

Jump to: navigation, search
Language Keyword

Declares a value as a local constant.


Syntax

Const constantname = value

Part Type Description
constantName String literal The name of the constant.
value Any data type. The value to assign to the constant.

Notes

The Const statement can be used in place of the Dim statement followed by an assignment statement when you are sure that the value of the variable should not change within the method. Using Const instead of Dim provides a convenient way to manage such values.

A Const
Changed 5.0
statement can be placed anywhere in a method, including inside a conditional structure, such as an If statement, or a looping structure.

Constants declared in this manner are local to the method. You can also create constants in a window, class, or module, as described in the User's Guide. Constants that belong to windows or classes can be public (accessible throughout the application), protected (accessible only within the object that owns the constant and its subclasses), or private (accessible only within the object that owns it). Modules can have global constants, accessible throughout the application.

Examples

The following constant is used to set a button’s caption.

Const Accept="OK"
BevelButton1.caption=Accept


The following sets the value of “Pi” for the method.

Const Pi=3.14159265358979323846264338327950

See Also

Dim statement.

Personal tools