Strange cannot expose a Friend type error

  • Thread starter Thread starter Gerard Stafleu
  • Start date Start date
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?
 
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]
 
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".
 
Back
Top