VB.NET TUTORIALS - VB.Net - Constants
VB.Net - Constants
ADVERTISEMENTS
Print and Display Constants in VB.Net
Constant | Description |
---|---|
vbCrLf | Carriage return/linefeed character combination. |
vbCr | Carriage return character. |
vbLf | Linefeed character. |
vbNewLine | Newline character. |
vbNullChar | Null character. |
vbNullString | Not the same as a zero-length string (""); used for calling external procedures. |
vbObjectError | Error number. User-defined error numbers should be greater than this value. For example: Err.Raise(Number) = vbObjectError + 1000 |
vbTab | Tab character. |
vbBack | Backspace character. |
ADVERTISEMENTS
Declaring Constants
[ ] [ accessmodifier ] [ Shadows ] Const constantlistADVERTISEMENTS
constantname [ As datatype ] = initializer
' The following statements declare constants. Const maxval As Long = 4999 Public Const message As String = "HELLO" Private Const piValue As Double = 3.1415Example
Module constantsNenum Sub Main() Const PI = 3.14149 Dim radius, area As Single radius = 7 area = PI * radius * radius Console.WriteLine("Area = " & Str(area)) Console.ReadKey() End Sub End ModuleDeclaring Enumerations
[ ] [ accessmodifier ] [ Shadows ] Enum enumerationname [ As datatype ] memberlist End Enum
[] member name [ = initializer ]
Enum Colors red = 1 orange = 2 yellow = 3 green = 4 azure = 5 blue = 6 violet = 7 End EnumExample
Module constantsNenum Enum Colors red = 1 orange = 2 yellow = 3 green = 4 azure = 5 blue = 6 violet = 7 End Enum Sub Main() Console.WriteLine("The Color Red is : " & Colors.red) Console.WriteLine("The Color Yellow is : " & Colors.yellow) Console.WriteLine("The Color Blue is : " & Colors.blue) Console.WriteLine("The Color Green is : " & Colors.green) Console.ReadKey() End Sub End Module