This should work also
Dim foo As Blah = CType(InputInteger, Blah)
Dim s As String = foo.ToString
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
I have this enum:
Friend Enum Blah As Integer
Zero = 0
One = 1
Two = 2
End Enum
I will get an integer and need to return the related string.
ie will need to convert 1 to One.
Select Case InputInteger
Case 0
Return Zero
...
End Select
This will work but a short direct convertion?
Thanks.
This should work also
Dim foo As Blah = CType(InputInteger, Blah)
Dim s As String = foo.ToString
Hi @StewartBW ,
You can achieve a more concise conversion from an integer to the corresponding enum name by using the Enum.GetName method.
Public Function ConvertIntegerToEnumName(value As Integer) As String
Return [Enum].GetName(GetType(Blah), value)
End Function
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.