For example, many places in the program code need to use pi, which can be defined first (Const? PI =3. 14), and then use pi to represent 3. 14. If hundreds of PIs are used in this question, if you want to modify its accuracy to 3. 14 1593, you only need to modify the constant value Const PI= 3. 14 1593 in the sentence to achieve the goal, without repeated modifications.
constant
A named item that holds a constant value when executing a program. A constant can be a string, a numeric value, another constant, anything (except the sum of powers)? A combination of arithmetic operators or logical operators. Each main application can define its own set of constants. Users can also define additional constants through the const statement. You can use constants anywhere in your code instead of actual values.
Const statement, declaring constants used to replace literal quantity.
Const statement example
This example uses the Const statement to declare constants that are used to replace text values. Public constants are declared in the general part of the standard module, not in the class module. Private constants can be declared in the public part of any module type.
Constants are private by default.
Const MyVar = 459
Declare a common constant.
Public Const MyString = "HELP "
Declare a private integer constant.
Private Const MyInt As Integer = 5
Declare multiple constants in one line.
Const MyStr = "Hello ",MyDouble As Double = 3.4567