3.7 Scope and Accessibility in Class Modules The
As we have discussed, if a member variable is declared using the Shared keyword, then it is shared by all objects in the class. More accurately, the member exists independently of any object of the class. In this case, the member can be accessed (within its scope) through qualification by the class name, as in: Class1.classvariable = 100 Note that the member can also be accessed through qualification by an object name, but this has the same effect as access through qualification by the class name there is only one copy of the member. If the member is declared without using the Shared keyword, then class/object access refers to accessibility through qualification by the name of an existing object, as in: Dim c As New Class1 c.classvariable = 100 The scope for class/object access can be one of the following: The declaring class only The declaring project The declaring project and any external software component that holds a reference to the declaring project Table 3-2 describes the effects of the various access modifiers. Table 3-2. Access modifiers in class modules Direct-access scope Class/object scope Private Declaring class Declaring class Protected All derived classes Declaring class Friend Derived in-project classes Declaring project Protected Friend All derived classes Declaring project Public All derived classes All projects Unfortunately, it does not seem possible to make a simple statement about the effect of the access modifiers Friend and Protected independently. It would have been much clearer to have separate sets of access modifiers for direct-access scope and class/object scope, instead of intertwining the concepts as shown in Table 3-2. Oh well.
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services