Constant Expression

Поскольку 3.17

Constant expressions are integer expressions that are evaluated at compile time, and that can be used in the following places: These expressions only support a subset of Gambas operators and pre-defined constants.

Here is what you can use inside a constant expression:

Arithmetic operators. +, -, *, /, \, DIV, %, MOD
Logical operators. AND, OR, XOR, NOT
Bitwise operators. Shl, Shr, Asl, Asr, Lsl, Lsr
Size of a native numerical or date datatype. SizeOf
Boolean constants TRUE, FALSE
Native datatype constants. gb.Boolean
gb.Byte
gb.Short
gb.Integer
gb.Long
gb.Single
gb.Float
gb.Date
Any private integer constant identifier previously declared.

In the context of constant integer expressions, The / operator acts like the integer division operator \.

Examples

Public Const Alpha As Integer = 1
Public Const Beta As Integer = (Alpha * 2) + 1
Public Const Delta As Byte = Beta + Alpha

Private Enum FirstFlag = 1 Shl 0, SecondFlag = 1 Shl 1, ThirdFlag = 1 Shl 2

Private SomeEmbeddedArray[Delta * SizeOf(gb.Short)] As String