QA: Using Enum.Parse to Convert a String to an Enumeration Value
I have a string that holds the name of a value from an enumeration. How do I “cast“ that to the actual enumeration type?
You can use the Parse method of the Enum class to do this conversion for you. Some sample VB code is shown below.
Dim dr As DialogResult
dr = CType([Enum].Parse(GetType(DialogResult), "Cancel"), DialogResult)