Visual Basic 2010 (Console) Guide
Enumerated Types
An enumerated type is a set of ordered values that can be used as constants in a program. In the example, the enumeration is a list of urgency markers for email messages.
Public Enum Importance
None = 0
Trivial = 1
Regular = 2
Important = 3
Critical = 4
End Enum
Sub Main()
Dim message1 As Importance = Importance.Regular
Dim message2 As Importance = Importance.Critical
Console.WriteLine("Importance Of Message 1 is {0}", message1)
Console.WriteLine("Importance Of Message 2 is {0}", message2)
Console.ReadLine()
End Sub
Notice the use of the Public keyword in the declaration of the enumerated list. This is an important term that makes this block of code accessible from other parts of the program.
The numbers can be omitted from the declaration. If they are, Visual Basic will assign the numbers automatically, starting, as it always does, from zero.
Having A Go
- Study the example above. Look back at the page on the Date structure. Use this information to output the date and time using words for the month and day.