Concept

# Constants

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

A constant is a fixed value.

## Notes

<span class="title-ref">Constants</span> can have a type of Number (see below), String, Boolean, Color or Text.

There are three main type of \`Constants\`:

- Local <span class="title-ref">Constants</span> that you define in your code using `Const</api/language/const>`. When defining a constant this way the data types is inferred if it is omitted.
- Project Item <span class="title-ref">Constants</span> that you define on the project item using the `Constant Editor</getting_started/using_the_ide/constant_editor>`.
- Localized Strings that you define on the project item using the `Constant Editor</getting_started/using_the_ide/constant_editor>`.

## Sample code

This is how you can declare <span class="title-ref">Constants</span> in code using the `Const</api/language/const>` command:

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

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Const</api/language/const>` command; `Constant Editor</getting_started/using_the_ide/constant_editor>`, `Variables and Constants</getting_started/using_the_xojo_language/variables_and_constants>`, `Modules</getting_started/using_the_xojo_language/modules>`, `Introduction to app localization</topics/localizing_your_apps/introduction_to_app_localization>` topics

</div>
