Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enumerated Types

Status
Not open for further replies.

kenbw

Programmer
May 2, 2002
39
US
I have an enumerated type and I am trying to figure out how to Parse it so I get the integer from the string. For Examples

Public Enum Emp
Director = 1
Associate = 2
Grunt = 3
End Enum

I want to be able to get at the number 1 by giving a string of Directory. I know I need to use the Parse command but am unsure how to do it. Any help would be appreciated.

Ken
 
KenBw,

Do you mean convert to Integer?

CInt(Emp.Director)

VarType(CInt(Emp.Director)).ToString 'returns Integer

HTH,


 
HTH,
No I mean I want to take the string "Director" and figure out the enumerated type associated with that word. Basically I want to go backwards then most. Most of the times you can set a enumerated type by usign the int, but I want to use the string value because thats all I have.

Ken
 
HTH,
I figured out what I needed to do. HEre is the code I ended up using:

Dim EmpType as Emp = Emp.Parse(GetType(Emp), "Director", True")

Thanks for trying though.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top