Results 1 to 5 of 5

Thread: [RESOLVED] Using a ENUM definition in class properties

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Resolved [RESOLVED] Using a ENUM definition in class properties

    In a global module, I define a new type that can take 4 values:

    Code:
    enum tAction as integer
       None
       Update
       Insert
       Delete
    end enum
    A use this type in many places in my code to check the value stored in a variable (if MyAction = tAction.Delete then ...)

    In a separate file, I define a class. One of the properties should return a value of this type:

    Code:
    public class XXX
    
    private _Action as tAction
    
    public property ClassAction() as tAction
      get
        return _Action
      end get
    end property
    
    end class
    This way I could check a class property in the same manner (if MyClass.ClassAction = tAction.Insert then ...)

    However I get a syntax error in the property definition: 'ClassAction' cannot expose type 'Globals.tAction' outside the project through class 'XXX'

    My entire program consists in a few modules, in a single project. How can I use my tAction definition in my classes?

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Re: Using a ENUM definition in class properties

    Even with PUBLIC, I still get the same error ...

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Using a ENUM definition in class properties

    There is probably an easier way...

    Code:
    Public Class XXX
    
        Private _Action As myEnums.tAction
    
        Public ReadOnly Property ClassAction() As myEnums.tAction
            Get
                Return Me._Action
            End Get
        End Property
    
    End Class
    Code:
    Module Module1
        'former location of tAction
    End Module
    
    Namespace myEnums
        Public Enum tAction As Integer
            None
            Update
            Insert
            Delete
        End Enum
    End Namespace
    Adding an Imports to Class XXX will aleviate the need for "myEnums." .
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    263

    Re: Using a ENUM definition in class properties

    I did not know I could use namespaces for this. I made the change and my program now works perfectly! THANKS

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