Name
Const Statement
Syntax
[accessmodifier] Constconstantname[Astype] =constantvalue
-
accessmodifier(optional; Keyword) One of the keywords
Public,Private,Protected,Friend, orProtectedFriend. For more information, see Section 4.7 in Chapter 4.-
constantname(required; String literal) The name of the constant.
-
type(optional; Keyword) The data type; it can be
Byte,Boolean,Char,Short,Integer,Long,Single,Double,Decimal,Date, orString, as well as any of the data types defined in the Base Class Library.-
constantvalue(required; Numeric or String) A literal, constant, or any combination of literals and constants that includes arithmetic or logical operators, except
Is.
Description
Associates a constant value with a name. This feature is provided to make code more readable. The name is referred to as a symbolic constant.
Rules at a Glance
The rules for
constantnameare the same for those of any variable: the name can be up to 255 characters in length and can contain any alphanumeric character, although it must start with an alphabetic character. In addition, the name can include almost any other character except a period or any of the data type definition characters ($, &, %, !).The
constantvalueexpression cannot include any of the built-in functions or objects, although it can be a combination of absolute values and operators. The expression can also include previously defined constants. For example:Private Const CONST_ONE = 1 Private Const CONST_TWO = 2 Private Const ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access