Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to iterate through enumeration in VB.net

Posted on 2008-10-08
1
2,434 Views
Last Modified: 2008-10-08
Hi,
I would like to iterate through an enumeration and capture the names and coresponding values. The problem I am running into, is when I attempt to capture the enumeration type using the following line:

Dim mytype As Type = Type.GetType("Bold.Providers.CRMDataProvider.CaseViews")

the type is "Nothing". Am I not correctly qualifying the namespace where my enumeration exists?


Dim mytype As Type = Type.GetType("Providers.CRMDataProvider.CaseViews")
            Dim names() As String = [Enum].GetNames(Type.GetType("Bold.Providers.CRMDataProvider.CaseViews"))
            Dim vals As Array = [Enum].GetValues(Type.GetType("Bold.Providers.CRMDataProvider.CaseViews"))
 
            For Each Name As String In names
                Debug.Print(Name)
            Next
 
            For Each value As Object In vals
                Debug.Print(value)
            Next

Open in new window

0
Comment
Question by:lbargers
1 Comment
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 125 total points
ID: 22673416
You can obtain the type by declaring a variable of that enumerated type and calling it's GetType function.  If you do that, you can be sure that Type returned will not be nothing.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question