Results 1 to 2 of 2

Thread: Enum or something else..??

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    4

    Unhappy Enum or something else..??

    Hi (first sorry for my bad english)


    i have follow code:
    VB Code:
    1. Public Const COMPANY_TABLE As String = "Company"
    2. Public Const COMPID_FIELD As String = "CompID"
    3. Public Const COMPANYNAME_FIELD As String = "Companyname"
    4.  
    5. Public Enum FIELDS
    6.    COMPID_FIELD
    7.    COMPANYNAME_FIELD
    8. End Enum

    now, i would like to get back for example the COMPANYNAME_FIELD Value.

    dim CompanyField as String = FIELDS.COMPANYNAME_FIELD
    CompanyField should be now "Companyname"

    I just want to list the possible fields in the .NET Environment
    ( public sub myFunction(byval Field as FIELDS) )

    Maybe there is another way how to do this?
    Last edited by RRDejaVu; Mar 12th, 2003 at 07:18 AM.

  2. #2
    Member
    Join Date
    Mar 2003
    Posts
    34
    If I understand the question correctly, the static GetValues() member of the enum type will return a string array, containg the enum item(s).

    Code:
    using System;
    
    class ListEnum {
    
        public enum Day {
            Morning,
            Afternoon,
            Evening
        }
    
        static void Main() {
            string[] enums = Enum.GetNames(typeof(Day));
            foreach(string e in enums) {
    	Console.WriteLine(e);
            }
         }
    }
    The code is in C#, but you can use the same logic for VB.NET.[
    Last edited by SimonVega; Mar 12th, 2003 at 10:56 AM.
    AKA 'Lethal'

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