
returning empty variant array from COM object?
I'm working from my memory here (not the best) so I apologize in
advance if I misstate something. However, let me offer my experience
with this.
It seems to me that I ran into the same problem trying to utilize some
vb objects from vbscript within an ASP. Specifically I could not
retrieve a variant array as a byref parameter of a subroutine no matter
how hard I tried. However, I WAS able to get it to work when I
returned the variant array as the return value of a function. For
example, suppose you have a VB class "Test" that has a function "List"
which returns a variant array. The following ASP will work:
<%
Set Test = Server.CreateObject("TestDLL.Test")
vList = Test.List()
%>
(1)=<%=vList(1)%><br>
(2)=<%=vList(2)%><br>
(3)=<%=vList(3)%><br>
(4)=<%=vList(4)%><br>
(5)=<%=vList(5)%><br>
Note that the above will NOT work unless you have the open and closed
parentheses after the method call: vList = Test.List() !!! Without
that, vbscript STILL will not correctly retrieve the variant array!
Once I got this to work for me I did not go any further into how to get
vbscript to retrieve a variant array as a byref parameter of a sub.
One would think this is possible!! Anyway, for what it's worth. Let
me know if this helps.
Quote:
> What is wrong with this???
> Com object.method definition...
> Public Sub foo(ByRef vArray As Variant)
> ...some code
> vArray.ReDim (x,y)
> ....code to open ADO recordset
> ....code to populate vArray...
> End Sub
> in vbScript...
> .
> Dim vArrayInput
> ' RDS is already created as a Remote Data Services Dataspace object
> Set MyObject = RDS.CreateObject("Object.class", "<%=server%>")
> Call MyObject.foo(vArrayInput)
> 'the object is properly created, and the call to the method is
successful
> 'however the input parameter array variable (vArrayInput) is
> 'properly dimensioned in the MyObject.foo method, but the array
> 'elements are all empty except for element (0,0) which is now set to
0.
> 'The call to MyObject.foo works perfectly using the same syntax on
> 'server side (ASP), and also from a call in a Visual Basic App.
> 'Any help or ideas is most appreciated!
Sent via Deja.com http://www.deja.com/
Before you buy.