[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?
Re: Using a ENUM definition in class properties
Make it Public Enum instead of just Enum
Re: Using a ENUM definition in class properties
Even with PUBLIC, I still get the same error ...
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." .
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