Reputation: 892
I'm looping through a collection of rows ordered by a field called "rIndex". I've created an Enum and assigned the name of the item to the number I want the index to be. For example
Public Enum RowOrder
RowA = 1 RowB = 3 RowC = 2
I'm using a select case to properly identify the rows I want out of the collection.
for each row in collection
Select Case row
Case rowA, rowB, rowC
row.rIndex = RowOrder.( 'I want to put the variable row name here, something like row.tostring )
Case Else
'Do nothing
next row
Does anyone know how to pass a variable to the field of an Enum so it will return its number?
Upvotes: 0
Views: 260
Reputation: 7449
Just need to cast your enum
variable to int
Dim value As Integer = CInt([Enum].Parse(GetType(RowOrder), [Enum].GetName(GetType(RowOrder), myRowOrder)))
Upvotes: 1