I created .NET DLL (COM interface). This assembly has a few classes and used for data retrieval. It worked fine before I created a class that has an array of other classes among other properties (class genCrvPoint has a few simple properties like date as-of, price, etc.):
After compiling and registering I created a following code in VBA
(note that method getCrw returns as BYRef argument an instance of the class crv):
Dim a as Object, ret as object, errmsg as String
Set a = CreateObject("MYlib.dbAccess")
Set ret = CreateObject("MYlib.crv")
If a.getCurrFwd(tck, errmsg, ret) = True Then
--------------------------------------------------
This code works fine until I try to reference an array of classes ret.pts(). Call to function UBound(ret.pts) returns correct number, but line Sheet1.Cells(2, 5 + i) = ret.pts(i).price produces error 450 "Wrong number of arguments or invalid property assignment".
In a debug mode, if I add object ret into the Watches window -- all properties of class ret are visible and store proper data including array of classes genCrvPoint (with all properties of each array element assigned to the correct data values). This means that data fetch, assignments, and marshalling works just fine.
But if I add ret.pts into the Watches window, a correct size array of elements each of type genCrvPoint is shown, but unfortunately instead of genCrvPoint properties each element is empty (<NO variables> for each array element).
So, I can get the data structures, can see them and actual data in the debug mode, but can't parse and assign them in VBA to variables or use them.
In any other language I would use casting. I tried assignements to variant data types without any success. Your suggestions will be appreciated.
ComVisible(True)> <COMCLASS()>PublicClass crv
----------------------------------------------------------------Private descr_ AsString
Private pts_() As genCrvPoint
PublicProperty pts() As genCrvPoint()
PublicProperty descr() AsString
End ClassPrivate pts_() As genCrvPoint
PublicProperty pts() As genCrvPoint()
Get
Set(ByVal value As genCrvPoint())
EndPropertyReturn pts_
EndGet
Set(ByVal value As genCrvPoint())
ReDim pts_(value.GetLength(0))
value.CopyTo(pts_, 0)
EndSetvalue.CopyTo(pts_, 0)
PublicProperty descr() AsString
Get
Set(ByVal value AsString)
EndProperty
Return descr_
EndGet
Set(ByVal value AsString)
descr_ = value
EndSet
EndProperty
After compiling and registering I created a following code in VBA
(note that method getCrw returns as BYRef argument an instance of the class crv):
Dim a as Object, ret as object, errmsg as String
Set a = CreateObject("MYlib.dbAccess")
Set ret = CreateObject("MYlib.crv")
If a.getCurrFwd(tck, errmsg, ret) = True Then
Sheet1.Cells(1, 4) = ret.descr
For i = 0 To UBound(ret.pts)
ElseFor i = 0 To UBound(ret.pts)
Sheet1.Cells(2, 5 + i) = ret.pts(i).price
.......
Next i.......
MsgBox (errmsg)
End If
--------------------------------------------------
This code works fine until I try to reference an array of classes ret.pts(). Call to function UBound(ret.pts) returns correct number, but line Sheet1.Cells(2, 5 + i) = ret.pts(i).price produces error 450 "Wrong number of arguments or invalid property assignment".
In a debug mode, if I add object ret into the Watches window -- all properties of class ret are visible and store proper data including array of classes genCrvPoint (with all properties of each array element assigned to the correct data values). This means that data fetch, assignments, and marshalling works just fine.
But if I add ret.pts into the Watches window, a correct size array of elements each of type genCrvPoint is shown, but unfortunately instead of genCrvPoint properties each element is empty (<NO variables> for each array element).
So, I can get the data structures, can see them and actual data in the debug mode, but can't parse and assign them in VBA to variables or use them.
In any other language I would use casting. I tried assignements to variant data types without any success. Your suggestions will be appreciated.