?
Solved

Enumeration error in interface module

Posted on 2007-11-13
4
Medium Priority
?
759 Views
Last Modified: 2012-06-27
Hi guys,
I've declared a Public enumeration (called MyRole) in a standard module and I can use it without any problems in all my class modules except in an interface module.

I get the following error message "'MyRole' cannot expose type 'GlobalDeclarations.MyRole' outside the project through interface 'MyInterface'". I can get around it by using String or Integer for example but I'd really like to use the enumeration, for obvious reasons.

Is there any way around it?

/Michael

'---GlobalDeclarations module
    Public Enum MyRole As Short
        Tender = 0
        Variation = 1
    End Enum

'---Class X module
Friend ReadOnly Property Role() As String Implements VarIF.MyRole
.......
End Property

'---VarIF interface module (that gives an error)
ReadOnly Property Role() As MyRole
0
Comment
Question by:gem56
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
doraiswamy earned 1000 total points
ID: 20278461
Why not declare the enum in the interface?
e.g.
Public Interface Interface1

    Enum MyRole As Short
        Tender = 0
        Variation = 1
    End Enum

    ReadOnly Property Role()

End Interface

Public Class Class1
    Implements Interface1
    Dim r As Interface1.MyRole = Interface1.MyRole.Tender

    Public ReadOnly Property Role() As Object Implements Interface1.Role
        Get
            Return r
        End Get
    End Property
End Class
0
 

Author Comment

by:gem56
ID: 20278669
Thanks for that doraiswamy. That's done the trick.

Just for future reference, is there no way of using an externally defined enumerations in an interface.
I ask that because it worked out OK this time but in future it may not be possible to relocate the declaration to the interface.

/Michael
0
 
LVL 8

Expert Comment

by:doraiswamy
ID: 20279162
To my current knowledge, no.
This is probably because the interface does not want any external dependencies. If what you were initially trying was allowed, then you would have to somehow bind your global module along with the interface. However by not specifying the return type of Role in the interface, I accomplished what you may want:

Public Interface Interface1
    ReadOnly Property Role()
End Interface

Module Module1
    Public Enum MyRole As Short
        Tender = 0
        Variation = 1
    End Enum
End Module

Public Class Class1
    Implements Interface1
    Dim r As Module1.MyRole = MyRole.Tender

    Public ReadOnly Property Role() Implements Interface1.Role
        Get
            Return r
        End Get
    End Property

End Class
0
 

Author Comment

by:gem56
ID: 20279333
Thanks a lot for your earlier solution doraiswamy and your explanation.
/Micael

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question