Enum With Numeric Members

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    #1

    Enum With Numeric Members

    VB.NET - VS 2005

    Is it possible to create an Enum with numeric members. Example:

    Public Enum NumberOfDecimal Places
    Auto
    1
    2
    3
    4
    5
    End Enum

    I want this for a property that I have in one of my controls. The
    "Auto" member is fine. The numbers generate errors.

  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: Enum With Numeric Members

    Paul wrote:
    VB.NET - VS 2005
    >
    Is it possible to create an Enum with numeric members. Example:
    >
    Public Enum NumberOfDecimal Places
    Auto
    1
    2
    3
    4
    5
    End Enum
    >
    I want this for a property that I have in one of my controls. The
    "Auto" member is fine. The numbers generate errors.
    >
    The identifiers in an enum has to be identifiers. The name of an
    identifier can not be a number.

    I suggest that you use a structure instead, having:

    :: a constructor that takes a number from 1 to 5
    :: a factory property named Auto that creates a zero value
    :: an IsAuto property that determines if the value is zero
    :: a Value property that returns the value

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

      #3
      Re: Enum With Numeric Members

      Göran,

      How about:

      Public Enum NumberOfDecimal Places
      Auto
      One
      Two
      Three
      Four
      Five
      End Enum

      Kerry Moorman

      "Göran Andersson" wrote:
      Paul wrote:
      VB.NET - VS 2005

      Is it possible to create an Enum with numeric members. Example:

      Public Enum NumberOfDecimal Places
      Auto
      1
      2
      3
      4
      5
      End Enum

      I want this for a property that I have in one of my controls. The
      "Auto" member is fine. The numbers generate errors.
      >
      The identifiers in an enum has to be identifiers. The name of an
      identifier can not be a number.
      >
      I suggest that you use a structure instead, having:
      >
      :: a constructor that takes a number from 1 to 5
      :: a factory property named Auto that creates a zero value
      :: an IsAuto property that determines if the value is zero
      :: a Value property that returns the value
      >
      --
      Göran Andersson
      _____
      Göran Anderssons privata hemsida.

      >

      Comment

      • Paul

        #4
        Re: Enum With Numeric Members

        Thanks for the replies. Kerry, I thought about your suggestion but I
        would prefer the user to be able to enter "2" or "0", actual numbers
        into the property.

        I also wondered if a Structure would work, but have not taken the time
        to investigate it. I'll look into it further.

        Thanks again!

        Comment

        • rowe_newsgroups

          #5
          Re: Enum With Numeric Members

          On May 8, 11:11 am, Paul <pwh...@hotmail .comwrote:
          Thanks for the replies. Kerry, I thought about your suggestion but I
          would prefer the user to be able to enter "2" or "0", actual numbers
          into the property.
          >
          I also wondered if a Structure would work, but have not taken the time
          to investigate it. I'll look into it further.
          >
          Thanks again!
          Thanks for the replies. Kerry, I thought about your suggestion but I
          would prefer the user to be able to enter "2" or "0", actual numbers
          into the property.
          Remember, they won't be entering in "2" or "0" but rather
          NumberOfDecimal s.2 or NumberofDecimal s.0

          Also, who are your users? Are they fellow programmers who are going to
          be using your code or just typical user who are using a full fledged
          application? If they are just normal users you could just have "Auto,
          1, 2, 3, 4, 5" as entries in a combobox and let the user select it
          there - there is no reason why the end-user should see the
          enumeration.

          Thanks,

          Seth Rowe

          Comment

          • Paul

            #6
            Re: Enum With Numeric Members

            The "users" are fellow developers. That is why I'm not concerned
            about using Auto, 1, 2... I'm just going to go with what I already
            used. I made the type be Integer and the Auto value will be -1.

            Comment

            Working...