Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 10

Setting a Reference to a COM Component

Your application must contain a reference to a component's Object Library before it can use the component's object classes.

An Object Library is a collection of information about an application's objects. You can find this information in a .TLB (Type Library) file, an .OLB (Object Library) file, or in an ActiveX server's EXE or DLL file.

To locate the COM component's Object Library, check the component application's documentation to see where it stores its Object Library.

However if the component in which you're interested has been properly registered in the Windows Registry, you won't ever need to know the name or location of the Object Library. Instead, the Windows Registry will contain information about the component in which you're interested. In that case, all you need to do is refer to the Windows Registry entries for the component, as in the following description.

In order to make a COM component's object model available to your application, you should execute the following steps:

STEP BY STEP
10.1 Making a COM Component's Object Model Available to Your Application

  1. Choose Project, References from the main VB menu.

  2. Scroll through the Available References list until you find the name of the COM component that you want (see Figure 10.1). The Object Library list you see here is not a VB-specific feature, but is generated from the Windows Registry.

    Use the References dialog box to set a reference in your project to a COM component.
    FIGURE 10.1 Use the References dialog box to set a reference in your project to a COM component.

  3. Click on Browse to find and select the TLB, OLB, EXE, OCX, or DLL file containing the server's Object Library if the server you need isn't in the list (see Figure 10.2).

    You can browse for the file containing a component's Object Library if the component isn't listed in the Available References list of the References dialog box
    FIGURE 10.2 You can browse for the file containing a component's Object Library if the component isn't listed in the Available References list of the References dialog box

  4. Select the desired COM component by clicking on the check box to the left of the server name.

  5. Click on OK in the References dialog box.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved