You use the Const statement
to declare a constant and set its value. By declaring a constant, you
assign a meaningful name to a value. Once a constant is declared, it
cannot be modified or assigned a new value.
You declare a constant within a procedure or in the declarations section of a module, class, or structure. Class or structure-level constants are Private by default, but may also be declared as Public for the appropriate level of code access.
You declare a constant within a procedure or in the declarations section of a module, class, or structure. Class or structure-level constants are Private by default, but may also be declared as Public for the appropriate level of code access.
To declare a constant
Write a declaration that includes an access specifier, the Const keyword, and an expression, as in the following examples:Public Const DaysInYear = 365 Private Const WorkDays = 250
To declare a constant that has an explicitly stated data type
Write a declaration that includes the As keyword and an explicit data type, as in the following examples:Public Const MyInteger As Integer = 42 Private Const DaysInWeek As Short = 7 Protected Friend Const Funday As String = "Sunday"
To declare multiple constants on a single line
Public Const Four As Integer = 4, Five As Integer = 5,
Six As Integer = 44