|
-
Nov 5th, 2011, 10:05 PM
#1
Thread Starter
Hyperactive Member
Enum Types
Can i get the name of the elements not the values?
Code:
Private Enum myName
Alex = 1
Bert = 2
Charlie = 3
Danny = 4
Evan = 5
End Enum
I want to list down the names not the values.
Thanks
-
Nov 6th, 2011, 01:43 AM
#2
Thread Starter
Hyperactive Member
Re: Enum Types
Another question, can i change the values of enum types during runtime?
-
Nov 6th, 2011, 02:12 AM
#3
Re: Enum Types
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
Last edited by Nightwalker83; Nov 6th, 2011 at 02:19 AM.
Reason: Fixed spelling!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 6th, 2011, 02:22 AM
#4
Re: Enum Types
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)
Last edited by Doogle; Nov 6th, 2011 at 02:26 AM.
-
Nov 6th, 2011, 11:27 AM
#5
Re: Enum Types
 Originally Posted by Doogle
I think OP is trying to use the Enum in 'reverse'. ... Only way I can think of is to have a 'look-up Table'
Agreed. And to the other question the OP asked, no, you cannot change the values during run-time. Enumerations are constant
-
Nov 7th, 2011, 09:02 PM
#6
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|