You are here:

C++/Using MSVC++ libraries in VB6


I am simply wanting to call a C++ function through Visual Basic 6.0, without making it dependent on any DLL files, or other files for that matter.

I want to make a simple, very basic, C++ function, and Reference it through VB.

What is the simplest way for me to compile C++ source code (I have access to MSVC++ but I do not care if it is another compiler), and to make it accessible through VB6 *WITHOUT* using Dynamic Linking: I need this to be a completely self-contained VB program.

I am getting frustrated as it seems like a simple concept, but I can't find any solution.  I have noticed that some references VB has in its list are "TLB" file extensions, or Type-libraries.  It is quite simple to create my own through VB, but when it comes to making one in C++, I only have choices of bloated object oriented projects which are confusing to understand.

Again, I am simply wanting to call a C++ function through VB, that's all! I know this may be possible through .NET, but I have VB6, not .NET.  

Is there something I am missing? Sorry if this is from my lack of reading the manuals. It seems that this should not be a problem but I cannot find any simple solution.

Thanks if you can help.

belltheo , Thank you for your question.

I believe that Visual Basic does not support mixed-language executables. So the only way you can execute nontrivial C++ code is to put it into an ordinary DLL and on the VB side load the DLL and call a function in the DLL. There are examples of doing this in the MSDN library; it is not clear from your question what error messages you might be receiving.

I suggest that you post this question at, which is more advanced than

David Spector


All Answers

Answers by Expert:

Ask Experts


David Spector


Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.


I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 All rights reserved.