Skip to content
Paul Squires edited this page Oct 14, 2026 · 2 revisions

Home › Variable Declarations › Const

Const

Non-modifiable variable declaration.

Syntax

Const symbolname1 [AS DataType] = value1 [, symbolname2 [AS DataType] = value2, ...]
Const [AS DataType] symbolname1 = value1 [, symbolname2 = value2, ...]

Description

Declares non-modifiable constant data that can be integer or decimal (floating-point) numbers or strings. The constant type will be inferred if DataType isn't explicitly given.

Specifying String * Size, Zstring * Size or Wstring * Size as DataType is not allowed.
Specifying String as DataType is tolerated but without effect because the resulting type is always a Zstring * Size.

Constants follow visibility rules similar to those of variables for Namespace blocks, Type blocks, and compound block statements.

Remarks

Differences from QB

  • QB does not support the As datatype syntax.

See also

Examples

Const Red = RGB(252, 2, 4)

Const Black As UInteger = RGB(0, 0, 0)

Const Text = "This is red text on a black bkgnd."

Locate 1, 1

Color Red, Black

Print Text

Sleep

End

Category: Variable Declarations
Kind: keyword


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally