Constants

Constants provide a way for representing an immutable value with an identifier. There could be situations in which your applications need to use the same value (which can be of any .NET type); therefore, it can be convenient to define an easy-to-remember identifier instead of a value. What would happen if such a value were a Long number? You declare constants as follows:

Const defaultIntegerValue As Integer = 123456789 Const aConstantString As String = "Same value along the application"

Constants are basically read-only fields that can be declared only at the module and class level or within a method and must be assigned with a value when declared. Constants within methods have public visibility by default, whereas constants at the ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.