Effect of Priority Setting in the References Dialog

Last reviewed: December 11, 1996
Article ID: Q142832
The information in this article applies to:

- Standard, Professional, and Enterprise Editions of Microsoft Visual

  Basic, 16-bit and 32-bit, for Windows, version 4.0

SUMMARY

At compile time, when Visual Basic is attempting to resolve a constant or class name, Visual Basic will search all of the references in the

'Available References:' list box in the References dialog, from top to
bottom. By changing the position of the files referred to in the 'Available References:' list box with the Priority buttons, the order that Visual Basic uses OLE Automation objects can be changed. Visual Basic uses the definition of the first object found that matches the name provided in code. For example, if OLE servers A and B define Window objects, and A is higher in the references list, Visual Basic resolves "Window" to "A.Window." You can make Visual Basic resolve "Window" to "B.Window" by moving B higher in the priority list than A.

Note: Changing the order of references in an existing project may break code. For example, given a project that has a reference only to OLE server A (which defines the only "Window" object) and code in 20 different modules that simply uses the syntax "Window". In this program all references to "Window" will resolve to "A.Window". Now suppose the need arises in a single module for a "Window" object provided by server B. While writing code in this module, a programmer switches the priority of server A and B so that the need to use "B.Window" is removed. This causes the code in the 20 other modules to break. Where "Window" used to resolve to "A.Window", it now resolves to "B.Window" because server B is listed before server A in the list of available references. In this case the references should be left in the original order and all calls to "Window" in the single module should be explicitly qualified (for example: "B.Window").

MORE INFORMATION

For more information on this subject, including other methods to manipulate the way Visual Basic chooses what object to use, please see the following article(s) in the Microsoft Knowledge Base:

   ARTICLE-ID: Q129867
   TITLE     : How to Debug Typelib Shadowing


Additional reference words: 4.00 vb4all vb4win
KBCategory: kbprg
KBSubcategory: iapole


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.