Enum question...

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

    Enum question...

    I need to declare a project level Enum that any procedure in any class can
    reference so there's continuity with the values.

    How do I do this?

    At present, if I declare a Module in a project and want to refer to it in an
    class I get the following error:

    [Method] cannot expose type [Enum] outside the project through class
    [ClassName]

    Example:

    Module Common
    Public Enum icPriority As Integer
    Low
    Medium
    High
    End Enum
    End Module

    (Separate Class file)

    Public Class Checker
    Public Sub DoCheck(ByVal p as NameSpace.Commo n.icPriority) ' This
    returns the squiggle with the error

    End Sub
    End Class


    How do I reference the global enum in a procedure as an parameter?

    Thanks,

    King Wilder
  • Kevin Spencer

    #2
    Re: Enum question...

    You can declare an enumeration at the namespace level, outside of any
    classes or modules.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    Chicken Salad Surgery

    Expect the unaccepted.

    "K. Wilder" <KWilder@discus sions.microsoft .comwrote in message
    news:FF0EAD26-1A35-43D4-B4F9-994FB2A836E3@mi crosoft.com...
    >I need to declare a project level Enum that any procedure in any class can
    reference so there's continuity with the values.
    >
    How do I do this?
    >
    At present, if I declare a Module in a project and want to refer to it in
    an
    class I get the following error:
    >
    [Method] cannot expose type [Enum] outside the project through class
    [ClassName]
    >
    Example:
    >
    Module Common
    Public Enum icPriority As Integer
    Low
    Medium
    High
    End Enum
    End Module
    >
    (Separate Class file)
    >
    Public Class Checker
    Public Sub DoCheck(ByVal p as NameSpace.Commo n.icPriority) ' This
    returns the squiggle with the error
    >
    End Sub
    End Class
    >
    >
    How do I reference the global enum in a procedure as an parameter?
    >
    Thanks,
    >
    King Wilder

    Comment

    • K. Wilder

      #3
      Re: Enum question...

      Kevin,

      Can you give me an example?

      My question was, how to enable a single Enum to be used globally throughout
      the project. I have been able to do what I want, but not using a globally
      available Enum. I've had to copy the Enum into each class that I needed to
      reference it.

      Is there a way to use and access a single Enum to be used globally for the
      project and use it in a procedure the way I described in my first post? If
      so, can you present me with an example or a explanation of how to do it?


      "Kevin Spencer" wrote:
      You can declare an enumeration at the namespace level, outside of any
      classes or modules.
      >
      --
      HTH,
      >
      Kevin Spencer
      Microsoft MVP
      Chicken Salad Surgery
      >
      Expect the unaccepted.
      >
      "K. Wilder" <KWilder@discus sions.microsoft .comwrote in message
      news:FF0EAD26-1A35-43D4-B4F9-994FB2A836E3@mi crosoft.com...
      I need to declare a project level Enum that any procedure in any class can
      reference so there's continuity with the values.

      How do I do this?

      At present, if I declare a Module in a project and want to refer to it in
      an
      class I get the following error:

      [Method] cannot expose type [Enum] outside the project through class
      [ClassName]

      Example:

      Module Common
      Public Enum icPriority As Integer
      Low
      Medium
      High
      End Enum
      End Module

      (Separate Class file)

      Public Class Checker
      Public Sub DoCheck(ByVal p as NameSpace.Commo n.icPriority) ' This
      returns the squiggle with the error

      End Sub
      End Class


      How do I reference the global enum in a procedure as an parameter?

      Thanks,

      King Wilder
      >
      >
      >

      Comment

      • Kevin Spencer

        #4
        Re: Enum question...

        Sure King:

        namespace DsiGlobal.Imagi ng
        {
        namespace Tiffs
        {
        /// <summary inherits="Syste m.Int32">
        /// Description of extra components.
        /// </summary>
        public enum ExtraSamples : int
        {
        /// <summary value="0">
        /// Unspecified
        /// </summary>
        Unspecified = 0,

        /// <summary value="1">
        /// Associated alpha data (with pre-multiplied color)
        /// </summary>
        AssociatedAlpha = 1,

        /// <summary value="2">
        /// Unassociated alpha data
        /// </summary>
        UnassociatedAlp ha = 2
        }

        // ...

        }
        }

        --
        HTH,

        Kevin Spencer
        Microsoft MVP
        Chicken Salad Surgery

        Expect the unaccepted.

        "K. Wilder" <KWilder@discus sions.microsoft .comwrote in message
        news:4DEC31FB-2753-435C-90F7-E6DF6199C5BC@mi crosoft.com...
        Kevin,
        >
        Can you give me an example?
        >
        My question was, how to enable a single Enum to be used globally
        throughout
        the project. I have been able to do what I want, but not using a globally
        available Enum. I've had to copy the Enum into each class that I needed
        to
        reference it.
        >
        Is there a way to use and access a single Enum to be used globally for the
        project and use it in a procedure the way I described in my first post?
        If
        so, can you present me with an example or a explanation of how to do it?
        >
        >
        "Kevin Spencer" wrote:
        >
        >You can declare an enumeration at the namespace level, outside of any
        >classes or modules.
        >>
        >--
        >HTH,
        >>
        >Kevin Spencer
        >Microsoft MVP
        >Chicken Salad Surgery
        >>
        >Expect the unaccepted.
        >>
        >"K. Wilder" <KWilder@discus sions.microsoft .comwrote in message
        >news:FF0EAD2 6-1A35-43D4-B4F9-994FB2A836E3@mi crosoft.com...
        >I need to declare a project level Enum that any procedure in any class
        >can
        reference so there's continuity with the values.
        >
        How do I do this?
        >
        At present, if I declare a Module in a project and want to refer to it
        in
        an
        class I get the following error:
        >
        [Method] cannot expose type [Enum] outside the project through class
        [ClassName]
        >
        Example:
        >
        Module Common
        Public Enum icPriority As Integer
        Low
        Medium
        High
        End Enum
        End Module
        >
        (Separate Class file)
        >
        Public Class Checker
        Public Sub DoCheck(ByVal p as NameSpace.Commo n.icPriority) ' This
        returns the squiggle with the error
        >
        End Sub
        End Class
        >
        >
        How do I reference the global enum in a procedure as an parameter?
        >
        Thanks,
        >
        King Wilder
        >>
        >>
        >>

        Comment

        Working...