Constants

From Xojo Documentation


Concept

A constant is a fixed value.

Notes

Constants can have a type of Number (see below), String, Boolean, Color or Text.

There are three main type of constants:

  • Local constants that you define in your code using Const. When defining a constant this way the data types is inferred if it is omitted.
  • Project Item constants that you define on the project item using the Constant Editor.
  • Localized Strings that you define on the project item using the Constant Editor.

Sample Code

This is how you can declare constants in code using the Const command:

Const kAnswerToLife As Integer = 42
Const kPi = 3.14156
Const kAppName As String = "MyApp"

See Also

Const command; UserGuide:Constant Editor, UserGuide:Variables and Constants, UserGuide:Modules, UserGuide:Localization topics