0
我有DLL函数,它有两个字符串参数和两个int参数。该函数返回一个字符串。当我直接从Excel中调用函数时,它是可以的,但是当我从VBA调用函数时,要传递给DLL函数字符串参数,这是不对应与原始(无意义字符)。并函数返回字符串,女巫有每秒char“”。Excel的VBA - 字符串参数传递从Excel但不是从VBA
我的DLL函数如下所示:
BSTR __stdcall getPattern(int sex, int pad, BSTR * a, BSTR * b){
...
}
声明函数在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
在Excel中我调用该函数是这样的:(它是OK)
=GetPattern(I5;C1;A1;B1)
而从VBA的调用函数是这样的:(只返回字符串的第一个字符)
result = GetPattern(Range("I5").Value, Range("C1").Value, Cells(i, 1).Value, Cells(i, 2).Value)
这会得到相同的结果。 –
偶然返回的字符串unicode? – Comintern