Strange cannot expose a Friend type error

G

Gerard Stafleu

I have a project with the following module:

Module mdlDeclarations
Public Enum getMethod
gmFirst
gmLast
End Enum
End Module

and the following class:

Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' Error
End Function
End Class

I made this class simply with Project|Add Class.

I get an error for argument a of the function xyz:
'a' cannot expose a Friend type outside of the Public
class 'clsTest'.

When I put clsTest inside a module it works fine:

Module mdlTest
Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' No error!
End Function
End Class

End Module

Any ideas what is going on?
 
H

Herfried K. Wagner [MVP]

Gerard Stafleu said:
I have a project with the following module:

Module mdlDeclarations
Public Enum getMethod
gmFirst
gmLast
End Enum
End Module

and the following class:

Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' Error
End Function
End Class

I made this class simply with Project|Add Class.

I get an error for argument a of the function xyz:
'a' cannot expose a Friend type outside of the Public
class 'clsTest'.

When I put clsTest inside a module it works fine:

Module mdlTest
Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' No error!
End Function
End Class

End Module

Any ideas what is going on?

http://www.google.de/groups?selm=#[email protected]
 
A

Armin Zingler

Gerard Stafleu said:
I have a project with the following module:

Module mdlDeclarations
Public Enum getMethod
gmFirst
gmLast
End Enum
End Module

and the following class:

Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' Error
End Function
End Class

I made this class simply with Project|Add Class.

I get an error for argument a of the function xyz:
'a' cannot expose a Friend type outside of the Public
class 'clsTest'.

When I put clsTest inside a module it works fine:

Module mdlTest
Public Class clsTest
Public Function xyz(ByVal a As getMethod) ' No error!
End Function
End Class

End Module

Any ideas what is going on?


In the first example, the Module is declared as "Friend" whereas the class
and it's function is public. As the module is friend, the contained Enum is
also Friend only, not public. A member can not be "more public" than the
containing class. Use "Public Module mdlDeclarations".
 

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

Top