access levels

A

Andy B.

Can somebody explain in somewhat easier terms what friend, protected,
private and protected friend do in the scope of a code block like a class, a
namespace and an assembly?
 
C

Cor Ligthert[MVP]

Andy,

It is always what is visible to you as you want to use it in your IDE.
It is always top down, so a private member in a class is visibe for a member
on a higher level.
AFAIK is this not used to give an access level of a namespace.

Be aware that the module is a strange duck in this.

Private has the same access level as Dim or nothing used in a Class
Protected with nothng means that it is private vissible in the class itself
and in all classes that inherits this class.
Friend means that it is visible in all classes in the project (assembly,
dll)
The sentence Protected Friend the same meaning as with Protected (private)
Public means that it is from everywhere visible

A module can only have Public (default) and Private, the Dim is Public at
module level.

Don't make the mistake to set all public as this looks easier, it is not the
less public and friends the easier becomes it making programs.
The more public friend you have the more members become ambigious and you
have to use them with their full namespace name.

Cor
 

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