Section 4.4. Enumerations


4.4. Enumerations

An enumeration appears as a group of related integer constants. All members of an enumeration share the same data type, and it must be an integral data type (Byte, Integer, Long, or Short, and alsoin 2005 or beyondSByte, UInteger, ULong, or UShort). The enumeration members are shared and read-only for the lifetime of the application.

     Public Enum VehicleType As Integer        bicycle = 2        tricycle = 3        passengerCar = 4        eighteenWheeler = 18     End Enum 

They are used in code just like constants or variables.

     Dim whatIDrive As VehicleType     whatIDrive = VehicleType.passengerCar 

Enumerations are declared at the namespace or module level only; you cannot define an enumeration within a procedure.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net