VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,749 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
How to assign a string to an enum in vb.net?
DirectCast([Enum].Parse(GetType(Blah), "Second"), Integer)
Option Strict On disallows implicit conversions from 'Integer' to blah.
Public Enum Blah
First
Second
Thirds
End Enum
It should be like this I think,
Dim blahVal As Blah = Blah.First
Dim parse As String = "second"
blahVal = DirectCast([Enum].Parse(GetType(Blah), parse, True), Blah)