---
title: "Constants"
canonical: "https://docs.cuesystem.com/space/CVCHELP/509018113/Constants"
format: markdown
---
> Macro (toc)

---

# Constants

A constant is a part of a program whose value cannot be changed. A constant can be declared only within a module or a class. A constant must be initialized by the const expression. The const expression is a constant value or can consist of more constant values.

#### Syntax

```visualbasic
[Accessibility] Const Name As DataType := ConstExpression [WithAttributes {Attribute1[, Attribute2, ..., AttributeN]}]
```

#### Attribute: Info

| Value type | Meaning | Example |
| --- | --- | --- |
| Text | Text which will be visible in a tooltip window for this constant. | Info := "Any text " |

#### Example

```visualbasic
// byte constant
Const MAX_TEMP As Byte := 30

// long constants
Const MINIMUM As Long := 2000
Const MAXIMUM As Long := 6000

// long constants defined by another constant
Const LOW_VAL As Long := MINIMUM + 100
Const MEAN_VAL As Long := (MINIMUM + MAXIMUM) / 2

// long constants defined as hexadecimal number
Const LOW_BYTE As Long := &H00ff
Const HIGH_BYTE As Long := &Hff00

// time constant
Const START_TIME As Time := #03/01/2009 12:30:00#

// double constant
Const PI As Double := 3.1415926535
Const PI2 As Double := 2 * PI

// double constant in exponential form
Const EXAMPLEC1 As Double := 1E-5     /* =  0.00001 */
Const EXAMPLEC2 As Double := 25E-5     /* =  0.00025 */
Const EXAMPLEC3 As Double := 25e4     /* =  250000.0 */
Const EXAMPLEC4 As Double := 13.1e+4     /* =  131000.0 */
Const EXAMPLEC5 As Double := 13.1e-4     /* =  0.00131 */
Const EXAMPLEC6 As Double := -13.1e+4     /* =  -131000.0 */
Const EXAMPLEC7 As Double := -13.1e-4     /* =  -0.00131 */

// Text constant
Const MESS_LONG_LINE As Text := "Line is too long! The following lines are ignored!"
```

It is very useful to declare length of an array by a constant. So the program code is more legible and a change of a length of the array is easy.

#### Example

```visualbasic
Const TEMPERATURE_COUNT As Long := 60

Private Process Autoexec()
  Var Temperature[TEMPERATURE_COUNT] As Long
  Var i As Long

  For i := 1 To TEMPERATURE_COUNT
    Temperature[i] := 20
  End For
End Process
```