Solved

How to iterate through enumeration in VB.net

Posted on 2008-10-08
1
2,419 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now