I have a test dll function that reads a string and display it:
int _stdcall test(LPSTR myString) {
MessageBoxA(NULL, (LPCSTR)myString, "test", MB_OK);
return 0;}
The excel VBA declaration is
Declare Function test Lib "test.dll" (ByVal text As String) As Long
There is a sub that calls the function. It reads an excel cell with value as "abcde" and is able to display a correct result. The sub code is:
sub testCode()
test (cells(1,1).value)
end sub
However when call the dll function using excel formula =test(A1)
, the message box only display the first char "a" of the string.
I had spent entire weekend reading BSTR, etc, still not be able to solve this. What is going on here?