Some variables don’t change value during the execution of program. These are constants that appear many times in your code. The constants are preferred for two reasons :
• Constants don’t change value
• Constants are processed faster than variables
The general form to declare a constant is as follows :
Const constantname [As type] =value
The As type part of the declaration is optional. If you omit it, the constant’s type is determined by the value you assign to it. Constants also have a scope and can be Public or Private.
e.g. Public Const pi as Double =3.14159265358979
Visual Basic uses constants extensively to define the various arguments of its methods and the settings of the various control properties.
Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses