I have created a vb GUI & a C dll but can't get them to link .I've tried Project -> references -> browse -> mydll.dll and I get an error "Can't add a reference to specified file" Any suggestion ? Please help.
You need to declare the function from your dll the way that you declare a function from a windows API. Then you can call the function from your VB code.
In this example from VB Programmers Journal the VB program is using a C++ dll.
Private Declare Sub ApplyXOR Lib "c:\VBEncrypt\debug\VBEncrypt.dll" (ByVal strData As String, ByVal lngLen as Long)
Then in code the function ApplyXOR is called like any other.
A good article on using C++ to enhance VB is available in VBPJ January 2001.
I'm no help to you there. I saw your post and thought immediately of the article from VBPJ- so I could help out w/that but you have now seen the extent of my knowledge in regards to using C++ with VB.
If you don't want to make your DLL a COM object, you can leave it as an ordinary C dll, and export the functions you want to call. The MS documentation says you can use the compiler pragma __declspec(dllexport), but it doesn't work when called by VB. You must use the old-school way of declaring your function as WINAPI, and including the function name in a .DEF file you make part of your VC++ project.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.