Results 1 to 5 of 5

Thread: So I have this Enum...Need Help

  1. #1

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681

    So I have this Enum...Need Help

    So I have this enum:
    VB Code:
    1. Public Enum xyz
    2.      x = 1
    3.      y = 2
    4.      z = 5
    5. End Enum

    And i want to have a Select Case that checks for any of the values in the enum (1,2,5) but I don't want to write out a case statement for each enumeration item. I would like to just write one case statement to determine if the value is in the enumeration like:
    VB Code:
    1. Select Case myInt
    2. Case In [Enum].GetValues(GetType(enuTopChainTypes))
    3. End Select

    Obviously this doesn't work, but I thing I am close. Anyone know how to do this?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    will something like this help you in any way :
    VB Code:
    1. Dim a As Integer
    2.  
    3.         Select Case a
    4.  
    5.             Case 1 To 4
    6.  
    7.             Case 5 To 9
    8.  
    9.             Case 10 To 14
    10.  
    11.         End Select

  3. #3

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Not really. You know how you can do:
    VB Code:
    1. Select Case x
    2. Case 1,2,5
    3. ...
    4. End Case

    Well, I want to use an array (that I get from the Enum.GetValues) instead of the 1,2,5. Or if there is some other way to do it...

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    How about this?
    VB Code:
    1. MsgBox([Enum].IsDefined(GetType(xyz), 1))

  5. #5

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    That will definitely work! Thanks dude!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width