Can i get the name of the elements not the values?
I want to list down the names not the values.Code:Private Enum myName
Alex = 1
Bert = 2
Charlie = 3
Danny = 4
Evan = 5
End Enum
Thanks
Printable View
Can i get the name of the elements not the values?
I want to list down the names not the values.Code:Private Enum myName
Alex = 1
Bert = 2
Charlie = 3
Danny = 4
Evan = 5
End Enum
Thanks
Another question, can i change the values of enum types during runtime?
This might be the only way to return the name of the Enum, taken from the FAQ here.
vb Code:
Dim MyVariable As MyValues MyVariable = First If MyVariable = Second Then MsgBox "This message will not be shown!" End If
That is you would use it like
vb Code:
Private Enum myName Alex = 1 Bert = 2 Charlie = 3 Danny = 4 Evan = 5 End Enum Private Sub Form_Load() Dim MyVariable As myName MyVariable = Danny If MyVariable = Danny Then MsgBox "Danny" End If End Sub
I think OP is trying to use the Enum in 'reverse'.
eg MyVariable = 4 and the MessageBox outputting 'Danny' - which is not what Enums do. Only way I can think of is to have a 'look-up Table' (eg an Array with the appropriate names in appropriate elements)
MsgBox strNames(myVariable)
Thanks All.