I have DLL function which has two string parameters and two int parameters. The function returns a string. When I call the function directly from excel, it is OK, but when I call the function from VBA, to DLL function is pass string params, which is not corresponding with original (nonsense characters). And function return string, witch have every seconds char " ".
My dll function looks like this:
BSTR __stdcall getPattern(int sex, int pad, BSTR * a, BSTR * b){
...
}
Declare function in VBA:
Declare Function GetPattern _
Lib "myPathToFunction" Alias "GetPattern" (ByVal poh As Integer, ByVal pad As Integer, ByRef a As String, ByRef b As String) As String
In excel I call the function like this: (And it is OK)
=GetPattern(I5;C1;A1;B1)
And from VBA call function like this: (and it return only first char of string)
result = GetPattern(Range("I5").Value, Range("C1").Value, Cells(i, 1).Value, Cells(i, 2).Value)