Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use a C coded module in VB?

Status
Not open for further replies.

rjr9999

Programmer
Apr 7, 2001
183
US
Is it possible for me to write a module in C for VB to use? And if so, will I be able to pass variables to and from that function? Rob
"Programming is like art...It makes me feel like chopping my ear off."
 
Yes, you can write a C DLL that you can pass information back and forth. When you write your functions, forget about using __declspec(dllexport), you'll need to include the name of the functions in a .DEF file

Chip H.
 
The chiph observation is right.

I just made a dll that is currently used in VB, two weeks before.
Even though in the MSDN documentation about DLL I read that you cannot create a MFC DLL for Visual Basic I found a workaround and I made my MFC DLL(much easier to contruct then a classic DLL) be used by VB.

The workaround was that I made public function call member functions of my CWinApp derived class, and voila it worked.

A very important issue to take into account when you create DLLs for vb is how to pass parameters and what calling convention to use. Also avoid using callback funtions even though you have the addressof operator in VB.
For that please read my question on the Visual C++ Forum:
"calling a DLL function from VB with ByRef arguments" thread
thread116-88011

Hope this helps, s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top