Link to home
Start Free TrialLog in
Avatar of AlexF777
AlexF777

asked on

Looking for an alternative to enumeration in C

something that would let me do this:

   Enum Color ( red = 0, yellow = 1, green = 2 )

if Color = red then ...
if Color = yellow then ...
if Color = green then ...

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You know VB already has a type that does just this :0


Dim myColor As ColorConstants
myColor = vbBlue

Select Case myColor
 Case vbRed
  MsgBox "You're Red"
 Case vbBlue
  MsgBox "Youre Blue"
 Case Else
  MsgBox "You're not red or blue :("
End Select
The advantage to using the 'ColorConstants' type is that you can freely apply it to other controls, it is the vb standard.

For example:


Dim myColor As ColorConstants
myColor = vbBlue

'// apply our color to the forecolor of a label
label1.forecolor = myColor  
Although, these suggestions do not really answer your question, however i felt it might be a good idea to shed some light on this.