Solved

VB6 project reference

Posted on 2009-07-09
4
162 Views
Last Modified: 2013-11-26
Is it possible to include a project reference to a dll in a VB6 project, and for the exe created from the project to run successfully without the dll on the users machine. The dll is a library of objects/functions that will be called only when the dll exists on the users machine, and otherwise the code create no objects using the dll. It appears though that windows checks for the dll at program start-up and bombs if it doesn't find it.

Reason I 'd like to include the dll is so I can code with early-binding/intellisense.

thanks.
0
Comment
Question by:bmutch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:stefanx
ID: 24817221
If you reference the Automation object in your VB Project, then the code is early bound when you compile and your exe will not run if the dll is not present. To prevent this, do NOT include the DLL reference in your VB Code, and use CreateObject to instantiate your Automation object dynamically.

Let's take an example where you want to access ADO, but don't know what version (if any) might be on your client's machine. Then, first of all, do NOT reference Microsoft ADO in your project. In your VB code, do the following

Sub DoIt
  Dim DBC AS Object
  Const ComponentName = "ADODB.Connection"

  On Local Error Resume Next
  Err.Clear
  Set DBC = CreateObject(ComponentName)
  If Err <> 0 then
    MsgBox "Sorry, ADO is not installed on this computer"
    Exit Sub
  End If
  MsgBox "The ADO Version installed on your machine is " & DBC.Version
  Set DBC = Nothing
End Sub
 
0
 

Author Comment

by:bmutch
ID: 24817396
yes, I know I can late reference it, and will do so if I have to. I guess you answered my question though. I wanted to add the reference so I could have early binding and intellisense, and still be able to run the program on a machine without the dll installed because I have a way of knowing if the dll is not installed and in my code I would not create any objects from the dll if it is not present. But apparently the program will not even run because it checks at startup to see if the dll is present?
0
 
LVL 8

Accepted Solution

by:
stefanx earned 250 total points
ID: 24817663
That's right - if it is early bound it tries to load the DLL on startup of the exe. No DLL, no starting of the exe.
0
 

Author Closing Comment

by:bmutch
ID: 31601784
thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question