O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determining the Values of Enumeration Elements

If you don’t want to use the default enumeration, you can change the enumeration to specify the values that work best for you, as shown in the following example:

Public Enum ContactCategory
    Family = 10
    Friend
    Acquaintance
    Colleague
    BusinessPartner
    Client  = 20
    Supplier
    ToAvoid = 30
    Company
    ContactPersonAtCompanyContact
End Enum

Running the same program again displays the value 14.

Duplicate Values Are Allowed!

Enumeration elements do not have to be unique. In the following example, BusinessPartner as well as ToAvoid have a value of 20 in the enumeration definition.

Public Enum ContactCategory Family = 10 Friend Acquaintance Colleague BusinessPartner = 20 Client Supplier = 19 ToAvoid Company ContactPersonAtCompanyContact ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required