?
Solved

How to add reference to certain Type Libraries programmatically in VB6 ?

Posted on 2008-11-04
11
Medium Priority
?
737 Views
Last Modified: 2012-06-21
I have a VB application which needs to be checked for available type libraries on application startup and set reference to appropriate type library.

Please explain with a code how to get/add/remove reference to certain Type Libraries programmatically in VB6 ?
0
Comment
Question by:pramodkumar
  • 6
  • 4
11 Comments
 
LVL 10

Accepted Solution

by:
c0ldfyr3 earned 2000 total points
ID: 22884424
Hey,

You can't programaticaly add or remove a reference to a library, you can't change a reference after compiling as it's used during the compile process.

What you're looking for is Late Binding. One major drawback is no intellisense but it works :)
Dm oObject As Object
Set oObject = CreateObject("My.Project")

Open in new window

0
 

Author Comment

by:pramodkumar
ID: 22906960
hi c0ldfyr3 !

Thanks for the comment :) !!
I got your idea of using late binding.

To be more clear about my scenario, my exe will depend on 2 tlbs while developing,
but after installation at the client PC,  i will be checking for any newer version of the tlbs.
If new version is found then the new available 2 tlbs at his system has to be referenced and if NOT then the available 2 tlbs at this system need to be referenced.

So, how can I make my exe to "refer" based on the result of the condition ?

Also, the objects are passed as parameters in various functions. Will it still work ?

Since I have to continue working on the same project later even after the release, it will be difficult for me to code without Intellisense.
Late binding is the only option ??
0
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 22907089
I'm afraid so, references are built into a project at compile time unfortunately =( What you can do, and what I've done in the past, is have two identical project files. One with references and one without. And you use the with-ref project file to develop and the without ref project file to build, then you swap around the declarations to be as object instead of as "ClassName" before building. It's messy as hell but it works!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:pramodkumar
ID: 22913438
ok  c0ldfyr3 ..

You kept your comment very neat and simple. Cause, even I too thought in your way of finishing all the coding jobs first with the references set and then create a copy, take off the references and do a quick "Find and Replace" thing with only the objects.

You caught my thought too ! :) ok.. i'm happy. I feel you are almost there, really close to win my 500 points.

Within 2-4 days I am going implement "late binding" and test it as like your comments. If it works perfect then you surely bag a huge 500 points for the same !! Or else i may need more help from you ;)

Kindly wait till I finish my testing and get back here.

Thanks a lot !! :)


0
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 22913898
Cool let me know if there's anything else I can do!
0
 

Author Comment

by:pramodkumar
ID: 22973586
Hi c0ldfyr3 !

Kindly give me some more time as I am little busy with some other modules of the application.
Will let you once I check late binding for the application.

thank you :)
0
 

Author Comment

by:pramodkumar
ID: 23032402
Hi c0ldfyr3 !
Very sry for making you to wait (if you are). The testing with late binding is yet to start since we loose the "intellisense" if we go for it right now. I am currently working with other modules..

Should I accept your answer for the moment for your courtesy shown in response to my question ? Moreover, I am having strong confidence in your answer that it will work, but cannot assure at the moment that it worked since I have to complete other modules..

Thank you :)
0
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 23035771
It doesn't bother me at all take your time - the points don't really make that much of a difference we do it to help ;)

I get emails when you reply so whenever you do get the time to revisit it just post a reply and I'll see what I can do to further assist you =)
0
 

Author Comment

by:pramodkumar
ID: 24533424
Many thanks c0ldfyr3 !!
It worked though the crude way !!
0
 

Author Closing Comment

by:pramodkumar
ID: 31513142
perfect answer !
0
 

Expert Comment

by:MPV557
ID: 25807228
I created a DLL library in Visual basic express edition 2008.  I followed the process of creating a reference on this the dll file.  This part is OK.

Now, I want to remove the reference  from my projoct and want include the class project (of this DLL) in the project group in order to debug the coding. What is the procedure for it.

I do appreciate your help.

Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 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