I have an object wrapper of some XLL functions in a VBA object, which object I am trying to translate to vb.net, as a COM dll add-in. The VBA declares the XLL functions like so:
Private Declare Function ExternalFunction Lib "C:\MyLibrary.xll" _
(ByVal x as double, ByVal y as double, ByVal Arr1D() as double, _
ByVal Arr2D() as double, ByVal ResultArray() as double, ByVal ErrorMssg as string) _
As Long
Of the first two array arguments, the first is one-dimensional and the second is two-dimensional. Because I will be sending a 2D array, vb.net forces me to change this part of the declaration from:
Arr2D() as double
to
Arr2D(,) as double
Should this work ok in the context of COM? I've spent a long time vetting every single input and I still get an error about the object disconnected from its clients. I could be missing something, but I"m worried that Function Declare and array rank, which were happy together in VBA, might not be happy now.
(Also, on a side note, curiously, I note that all the arguments are declared as ByVal--while the function most definitely will change ResultArray and ErrorMessage (those are the real returns...). How is it that the ByVal declaration even works in VBA--which it does. COuld my problem be that those should be ByRef, and vb.net is less forgiving?)
EDIT: Ok going back to the VBA. I see now that in the dozen or so functions that are wrapped, some have ResultArray sent ByRef and some send it unqualified. So Visual Studio stuck that ByVAl in there. That is probably my problem I guess. I'd still appreciate any reassurance if possible that the vb.net form of declaring rank of an array argument should be ok, if I could. (Curiously, to me, all the ErrorMessage strings are declared in VBA as ByVal--and they do work to return error messages from the XLL...)