Become acquainted with the Friend keyword in VB6
Takeaway: When writing property procedures and methods for a VB6 class, you can use the Friend keyword when you want a property or method to be accessible to other objects in the project but not to the project as a whole. Peter Aitken provides an introduction to the Friend keyword.
When writing property procedures and methods for a VB6 class, there are three keywords that you can use to control access to the property or method. Two of these are straightforward and easy to understand:
The third keyword is Friend, and its use and meaning are not well understood. You use Friend when you want a property or method to be accessible to other objects in the project but not to the project as a whole. Or, within a component, objects can access each other's Friend members, but the program that is using the component cannot.
For instance, suppose you're writing a component as a DLL or ActiveX, and there are several objects in the component that need to communicate with each other. However, you don't want this communication channel to be available to the program that is calling the component. This is perhaps the most common use of Friend properties and methods.
Friend properties and methods are not part of a class's interface. Also, they don't appear in the type library of the class, and they aren't included when you implement an interface using the Implements keyword.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Microsoft SQL Server 2005: Deployment and Tests in an iSCSI SAN Dell EqualLogic
- Next Generation Mobility Now Sprint
- Does fragmentation affect SANs, NAS, and RAID? Diskeeper
- Defrag Myth Busters - What You Should Know Diskeeper
- New Release - Diskeeper 2008 with InvisiTasking: It's Smart. It's Transparent. It Will Take Your PC from Zero to Sixty--Automatically! Diskeeper
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
