Scope error: "public" member not found in "friend" class/sub

G

Guest

I have encountered a situation that I don't understand. When I call a sub of
Friend scope (in an object with Friend scope), I am getting an error "Public
member 'subname' not found in type 'myType'". Any idea why? Since Friend
scope should be visible within my assembly, and everying is taking place
within a single project, I don't understand why this error is occuring.

Here is some illustrative code, where I would get the error in the
"MyA.MySub" line in class B:

Friend Class A
Friend Sub MySub()
....do some stuff
End sub
End class

Friend Class B
Friend Sub AnotherSub()
Dim myA as New A
myA.MySub()
End Sub
End Class

--- end code sample

If I change the scope of MySub from Friend to Public, the error goes away,
but it doesn't make sense to me to have a Public sub in a Friend class. I
would like to understand why I am getting the error in the first place.

Thanks in advance!

Tim
 
H

Herfried K. Wagner [MVP]

timbobd said:
I have encountered a situation that I don't understand. When I call a sub
of
Friend scope (in an object with Friend scope), I am getting an error
"Public
member 'subname' not found in type 'myType'". Any idea why? Since Friend
scope should be visible within my assembly, and everying is taking place
within a single project, I don't understand why this error is occuring.

Here is some illustrative code, where I would get the error in the
"MyA.MySub" line in class B:

Friend Class A
Friend Sub MySub()
....do some stuff
End sub
End class

Friend Class B
Friend Sub AnotherSub()
Dim myA as New A
myA.MySub()
End Sub
End Class

--- end code sample

If I change the scope of MySub from Friend to Public, the error goes away,
but it doesn't make sense to me to have a Public sub in a Friend class. I
would like to understand why I am getting the error in the first place.

The snippet you posted compiles in VS.NET 2003 and VS 2005.
 

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