Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 project reference

Posted on 2009-07-09
4
Medium Priority
?
166 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 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