LibreOfficeDev 25.8 Help
xPBxj‖Defines one or more identifiers as constants.
4sYHn‖A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified.
oPee4‖
QZJkC‖[Global|Private|Public] Const name = expression[, ...]
vwgLi‖ name: Any identifier that follows the standard variable naming conventions.
rEzJV‖expression: Any literal expression.
C8b4Z‖The data type must be omitted. When a library gets loaded in memory, LibreOfficeDev Basic converts the program code internally so that each time a constant is used, the defined expression replaces it.
QwPhy‖By default constants are defined as private in modules and routines. Constants can be made public or global in order to be used from all modules, from all Basic libraries.
EAL5T‖Global, Private and Public specifiers can only be used for module constants.
7HRGK‖Const EARTH = "♁" ' module scope
pCVMW‖Private Const MOON = "☾" ' module scope
xjhjq‖Public Const VENUS="♀", MARS="♂" ' general scope
6LzLX‖Global Const SUN = "☉", STAR = "☆" ' general scope
Sub ExampleConst
QegxQ‖ Const SUN = 3 * 1.456 / 56 ' SUN is local
U4Met‖ MsgBox SUN,, MOON ' SUN global constant is unchanged
Const Pgm = "Program", Var = 1.00
MsgBox Pgm & " " & Var, , VENUS &" and "& MARS
End Sub