Results 1 to 4 of 4

Thread: [RESOLVED] Return Description from Enum List

Threaded View

  1. #1

    Thread Starter
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Resolved [RESOLVED] Return Description from Enum List

    Hi all
    I have a user-defined class question. In my class I use an enumerated list for product type. I can read and write this value to an instance of the class.
    What I need to do now is read the string value for the instance from the enumerated list.

    Here's what I have so far.
    The ProdDesc property should, for example, retun a value of "Desktop" when privProdType = 1.
    I'm hoping I can do this without using a SELECT CASE syntax. (The Product list is much longer in real life.

    VB Code:
    1. Dim privProdType As Product
    2.  
    3. Public Enum Product
    4.     Desktop = 1
    5.     Notebook = 2
    6.     Server = 3
    7.     Printer = 4
    8.     'etc, etc
    9. End Enum
    10.  
    11. Public Property Let ProdType(newType As Product)
    12.     privProdType = newType
    13. End Property
    14.  
    15. Public Property Get ProdType() As Product
    16.     ProdType = privProdType
    17. End Property
    18.  
    19. Public Property Get ProdDesc() As String
    20.     'some code to get the desc from the Enum list - based on privProdType
    21. End Property
    Last edited by DKenny; Dec 15th, 2005 at 11:31 AM.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

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