I have a test DLL function that reads a string and displays it:
int _stdcall test(LPSTR myString) { MessageBoxA(NULL, (LPCSTR)myString, "test", MB_OK); return 0;}
Excel vba ad
Declare Function test Lib "test.dll" (ByVal text As String) As Long
There is a sub function that calls the function. It reads an excel cell with the value "abcde" and can display the correct result. Subcode:
sub testCode() test (cells(1,1).value) end sub
However, when you call the dll function using the formula excel =test(A1) , only the first char "a" line is displayed in the message box.
I spent the whole weekend reading BSTR, etc., I still canβt solve it. What's going on here?
source share