Switch accepts a number and returns a string but I need to pass a string and return a number.
Is there a command like switch that does this? I tried Enum but it won't accept variable names.
I have this working but can't help feeling there another way??
Is there a command like switch that does this? I tried Enum but it won't accept variable names.
I have this working but can't help feeling there another way??
Code:
Function GetTheInteger(nn As String) As Integer
'Define number for nn
Dim Lvalue As Variant, n As Integer
Lvalue = Array("", "One", "Two", "Three", "Four", "Five")
For n = 1 To 5
If Lvalue(n) = nn Then
GetTheInteger = n
Exit Function
End If
Next
End Function