您可以使用 Const 语句在 BSL 中创建用户定义的常量。使用 Const 语句,可以创建具有有意义名称的字符串或数字常量,并为其赋予文字值。
例如:
Const MyString = "This is my string." Const MyAge = 49
注:
字符串文字以引号 ("") 括起来。引号是区分字符串值与数值的最明显方式。以下示例说明了创建常量的用法:
示例 1:
Const MyString = "This is my string." 'Defines a string constant.
示例 2:
Const MyAge = 49 'Defines a numeric constant.
示例 3:
Const Pi = 3.14159, E = 2.71828, Gravity = 9.81 'Defines multiple numeric constants.
示例 4:
Const Greeting = "Hello," Const Name = "Alice" Dim WelcomeMessage WelcomeMessage = Greeting & Name 'Combines string constants. 'WelcomeMessage 'has string value: Hello, Alice