0

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?

Ccorock
  • 892
  • 12
  • 37
  • I would think an Enum being just an array would have some kind of method to search through it, or at least an exposed function to harvest this information from it. – Ccorock Nov 05 '12 at 19:51

1 Answers1

1

Just need to cast your enum variable to int

Dim value As Integer = CInt([Enum].Parse(GetType(RowOrder), [Enum].GetName(GetType(RowOrder), myRowOrder)))
Emmanuel N
  • 7,350
  • 2
  • 26
  • 36