CONST
来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgConst 最后更新: 2017-09-18
声明不可更改的常量数据。
语法
Const symbolname1 [As DataType] = value1 [, symbolname2 [As DataType] = value2, ...]或
Const [As DataType] symbolname1 = value1 [, symbolname2 = value2, ...]说明
声明不可更改的常量数据——整数、十进制(浮点数)或字符串。如果未显式给出 DataType,将推断常量类型。
String * size、Zstring * size 或 Wstring * size 不允许作为 DataType。将 String 指定为 DataType 是被容忍的,但没有任何效果,因为结果类型始终是 Zstring * size。
常量遵循与变量类似的可见性规则,适用于命名空间块、类型块和复合块语句。
示例
vb
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与 QB 的差异
- QB 不支持
As datatype语法。