error: Cannot expose a friend type outside of public class

G

Guest

Hi all

I'm getting the following error: "Cannot expose a friend type outside of public class". I created a module with an enum in it. I'm trying to use the enum as a parameter in a sub

----------------------------------------------------------------
-----in the module----
Public Enum LayerTyp
x
ca
End Enu

-----in a class----
Public Sub New(ByVal Type As LayerType
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?QXJ0?= said:
I'm getting the following error: "Cannot expose a friend type outside of public class". I created a module with an enum in it. I'm trying to use the enum as a parameter in a sub:

-----------------------------------------------------------------
-----in the module-----
Public Enum LayerType
xs
cat
End Enum

-----in a class-----
Public Sub New(ByVal Type As LayerType)

Make you sure you are using a 'Public Module'.
 
J

Jay B. Harlow [MVP - Outlook]

Art,
In addition to Herfried comments.

I would move the Enum outside any Module or Class.

-- in MyFile.vb --
Option Strict On
Option Explicit On

Public Enum LayerType
xs
cat
End Enum

Friend Module MyModule
End Module

Public Class MyFile
Public Sub New(ByVal Type As LayerType)
End Sub
End Class

-- in MyFile.vb --

Although VB6 requires that an Enum be inside a Class or Module, VB.NET does
not require this. I only put the Enum inside a specific Class or Module when
the Enum is an implementation detail specific to that Class or Module.

Hope this helps
Jay

Art said:
Hi all!

I'm getting the following error: "Cannot expose a friend type outside of
public class". I created a module with an enum in it. I'm trying to use
the enum as a parameter in a sub:
-----------------------------------------------------------------
-----in the module-----
Public Enum LayerType
xs
cat
End Enum

-----in a class-----
Public Sub New(ByVal Type As LayerType)
that, once again, I have some basic misunderstanding of how this OOP stuff
works. Can anyone tell me what I'm doing wrong?
 

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