Accessibility in Class Modules
The notion of accessibility (or scope) in class modules is more involved than it is in standard modules. As far as local variables (block-level and procedure-level) are concerned, there is no difference — we have block scope and procedure-level scope.
However, members of a class module can be assigned one of the following access modifiers:
PublicPrivateFriendProtectedProtected Friend
(For standard modules, only Public,
Private, and Friend are
allowed.)
Actually, we can dispense with the Protected
Friend modifier in one statement:
Protected
Friend is equivalent
to Protected or Friend. Put
another way, if Protected sets a specific range of
accessibility (or inheritance — see below) and
Friend sets a different range, then
Protected
Friend sets
accessibility to the union of those
ranges — if a member falls into either
range, it passes the accessibility (or inheritance) criterion.
Note that class modules themselves can be declared with any one of
the three access modifiers: Public,
Private, or Friend
(Protected is not allowed). When a class module
declaration specifies one of these access modifiers, this simply
restricts all of its members to that level of access, unless a
member’s access is further restricted by the access
modifier on the member declaration itself. For instance, if the class
has Friend access, no member can have
Public access. (Put another way, the
Public access is overridden by the
Friend class access.)
On the other hand, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access