473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Dec 17 '05 #1
1 2221
"timbobd" <ti*****@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: Zeng | last post by:
It's so messy w/o the "friend" relationship. Does anyone know why it was not supported in C#. It's almost about as bad as it doesn't support the inheritance hierarchy and method reference...
3
by: Quimbly | last post by:
Is there such a thing in C#? I know of the internal class modifier, but I want to grant "friend"-like access to a particular class from a different assembly. The reasons why I need this are...
1
by: Joe Carner via .NET 247 | last post by:
First time posting, thanks in advance for any help you can give me. Basically I am trying to a class that i want to be able to access the private data members of another class, both of which i...
0
by: VB Programmer | last post by:
I wanted to access some properties of a panel control that is on a different form. So, I went to the (Declarations) section of my main form (the form with the panel) and changed the panel (called...
0
by: AndyB | last post by:
I'm using xsd.exe to generate a typed-dataset. Then using typed dataset tables (datatables containing two columns--a name and a value) to bind to ASP.NET dropdown list controls (for the dropdown...
4
by: KriS | last post by:
Hi, I have two simple questions: 1) Do I have to write storage-class-specifier, when I want to declare a class as friend: class Bar {}; class Foo { friend ??? Bar; };
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
3
by: Joel Moore | last post by:
Is there any point to making classes or interfaces public in an EXE project? Executables can't be referenced by other applications so why would you ever need public classes? Do people leave...
12
by: MiG | last post by:
Hello, Consider the following code snippet: class B { protected: B() {} ~B() {} };
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.