Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Symbolic Constants
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Symbolic Constants
■ Visual Basic provides symbolic constants that can be used in place of
numeric or string values. The following code declares two symbolic
constants and uses one to dimension an array:
CONST MAXCHARS% = 254, MAXBUF% = MAXCHARS% + 1
DIM Buffer%(MAXBUF%)
■ The name of a symbolic constant follows the same rules as a Visual Basic
variable name. You can include a type-declaration character (%, &, #, !,
@, or $) in the name to indicate its type, but this character is not part
of the name. For example, after the following declaration, the names N!,
N#, N$, N%, N&, and N@ cannot be used as variable names because they have
the same name as the constant:
CONST N = 45
■ A constant's type is determined either by an explicit type-declaration
character or the type of the expression. Symbolic constants are not
affected by DEFtype statements. See: ◄DEFtype Statements►
■ If you omit the type-declaration character, the constant is given a type
based on the expression assigned to it. Strings always yield a string
constant. With numeric expressions, the expression is evaluated and the
constant is given the simplest type that can represent it. For example,
if the expression gives a result that can be represented as an integer,
the constant is given an integer type.
See: ◄Constants Summary►