Writing and then Calling a C++ DLL from Excel VBA -
Writing and then Calling a C++ DLL from Excel VBA -
i using visual studio 2010 write 32 bit dll in c++ intend phone call excel vba.
the c++ cpp file contains this:
#include "windows.h" #include "stdafx.h" int _stdcall fngetdata (const lpcstr sometext) { messageboxa(0, sometext, "wizzle wuzzle", mb_ok | mb_iconinformation); homecoming 42; }
while def file has this:
library getpdata exports getdata=fngetdata
the excel vba this:
alternative explicit private declare function getdata lib "getpdata.dll" (byref sometext string) integer public sub passsometext() dim ret integer, sometext string sometext = "hello excel subroutine." ret = getdata(sometext) end sub
the code compiles fine, , produces dll. when phone call function in dll excel vba, text in messagebox garbled nonsense:
i seeing text representation of pointer? how text value excel vba passed in?
figured out post question. reply alter byref byval in vba function declaration:
private declare function getdata lib "getpdata.dll" (byval sometext string) integer
c++ vba
Comments
Post a Comment