Global Enum question

B

BobRoyAce

I have a module that defines, among other things, an Enum:

--- MODULE CODE BEGINS ---
Namespace OMEGA.GRP
Module Globals
...
Public Enum FileProcessingStatus
None
Processing = 1
Completed = 2
Failed = 3
End Enum
...
End Module
End Namespace
--- MODULE CODE ENDS ---

Then, in a class module file, I have:

--- CLASS CODE BEGINS ---
Public Class clsFileProcessor
...
Private _ProcessingStatus As FileProcessingStatus
...
Public ReadOnly Property ProcessingStatus() As FileProcessingStatus
Get
Return _ProcessingStatus
End Get
End Property
...
End Class
--- CLASS CODE ENDS ---

This will not compile...get error message:
'ProcessingResult' cannot expose type
'OMEGA.GRP.Globals.FileProcessingStatus' outside the project through
class 'clsInputfeedFileProcessor'. C:\...\Classes
\clsInputfeedFileProcessor.vb

I have only a single project within the solution. I addition, when I
remove the Namespace declaration in the first quoted module, the error
message still occurs.

What am I doing wrong here and how do I fix it? The bottom line is
that I would like to define some global Enums that can be used
throughout the various forms and classes of the application.
 
H

Herfried K. Wagner [MVP]

BobRoyAce said:
Namespace OMEGA.GRP
Module Globals

Note that this will implicitly mark the module as 'Friend', which is less
visible than 'Public'.
Public Enum FileProcessingStatus
None
Processing = 1
Completed = 2
Failed = 3
End Enum
...
End Module
End Namespace
--- MODULE CODE ENDS ---

Then, in a class module file, I have:

--- CLASS CODE BEGINS ---
Public Class clsFileProcessor
...
Private _ProcessingStatus As FileProcessingStatus
...
Public ReadOnly Property ProcessingStatus() As FileProcessingStatus
Get
Return _ProcessingStatus
End Get
End Property
...
End Class
--- CLASS CODE ENDS ---

This will not compile...get error message:
'ProcessingResult' cannot expose type
'OMEGA.GRP.Globals.FileProcessingStatus' outside the project through
class 'clsInputfeedFileProcessor'. C:\...\Classes
\clsInputfeedFileProcessor.vb

I suggest to remove the module completely. Enumerations are types, so you
do not need to nest them inside modules.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top