【发布时间】:2015-04-17 12:18:50
【问题描述】:
我有 DLL 函数,它有两个字符串参数和两个 int 参数。该函数返回一个字符串。当我直接从excel调用函数时是可以的,但是当我从VBA调用函数时,DLL函数是传递string params,与原始不对应 (废话字符)。和函数返回字符串,女巫有每秒钟的字符“”。
我的 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中我这样调用函数:(没关系)
=GetPattern(I5;C1;A1;B1)
从 VBA 调用函数是这样的:(它只返回字符串的第一个字符)
result = GetPattern(Range("I5").Value, Range("C1").Value, Cells(i, 1).Value, Cells(i, 2).Value)
【问题讨论】: