returning empty variant array from COM object? 
Author Message
 returning empty variant array from COM object?

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!



Sun, 15 Sep 2002 03:00:00 GMT  
 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.


Fri, 04 Oct 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. call to COM object returns empty variant array???

2. JavaScript access variant array returned by COM object?

3. Type Mismatch returning variant array from COM object

4. Com+ returns variant array, but

5. Com+ returns variant array, but

6. Pass Variant Array to a COM Object

7. CDec returns empty variant

8. Empty Variant Returned from VB DLL

9. Returning array from COM object

10. Returning Arrays from COM object

11. returning an array of doubles from a COM object to VBScript

12. COM object Returning Array

 

 
Powered by phpBB® Forum Software