Often, the best way to implement an object-oriented algorithm is with two or more cooperating classes. These classes need to share data with each other, but not with other classes. Many object-oriented languages provide a Friend
modifier to allow classes to share data with each other and Visual Basic is no exception.
Unfortunately, Visual Basic’s interpretation of friends is pretty loose. Most languages that support the Friend concept allow you to say who your friends are. Visual Basic only allows you to say that you have friends. If anybody is your friend, then everybody is your friend. Or, more specifically, everyone in your component is your friend and everybody else doesn’t know you. Again, this works fine if everybody in your component behaves. But the implicit assumption is that you won’t put totally unrelated classes in the same component. Well, guess what the VBCore component does?
We’ll be using the Friend keyword to share data between classes when we get to the CRegNode and CRegItem classes in Chapter 10. The Friend keyword can also be used to make class data available to standard modules and forms within the component. You can see this in the CTimer class (TIMER.CLS).