Results 1 to 3 of 3

Thread: how to search an enum variable for a specific member?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Question how to search an enum variable for a specific member?

    I have declared an enum as

    enum PaymentFrequency : int

    {
    Monthly = 12,
    Quarterly = 4,
    SemiAnnual = 4,
    Annual = 1

    };

    in the method I am writing, the parameter passed is any one of items in the enum (say Annual).

    How to search an enum variable for 'Annual' and get the value which is 1 here.

    thanks
    nath

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how to search an enum variable for a specific member?

    You don't search for enum values. They simply are. If the variable is of that enum type, then the variable's value would be the value you are looking for,.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: how to search an enum variable for a specific member?

    Quote Originally Posted by bnathvbdotnet
    I have declared an enum as

    enum PaymentFrequency : int

    {
    Monthly = 12,
    Quarterly = 4,
    SemiAnnual = 4,
    Annual = 1

    };

    in the method I am writing, the parameter passed is any one of items in the enum (say Annual).

    How to search an enum variable for 'Annual' and get the value which is 1 here.

    thanks
    nath
    cast it to (int)
    or use a switch
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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