Passing Arrays to COM Components 
Author Message
 Passing Arrays to COM Components

Hello
        I have a COM component method which requires an Array as an input
parameter.  I am attempting to call this method from within my VB Script.
However I get a Type mismatch.  Is their any way to pass an Array to a COM
component or is it necessary to change the types to Variants.

All advise appreciated.

Thanks

--
Peter Barber



Fri, 01 Mar 2002 03:00:00 GMT  
 Passing Arrays to COM Components

You don't say what language the COM component is written in, so I'll assume VB.  Here's what does and doesn't work for me:

set obj = createobject("myserver.thing")
ar = array("A","B")

'In all PassArray variations, the function returns the
'UBound of the passed array.  The VB Function
'definition is included here for each variation...
'
'Public Function PassArray(ByRef vArray() As Variant)
'
'msgbox obj.passarray(ar) 'this fails (still ByRef)
msgbox obj.passarray((ar)) 'this works (forces ByVal)

'Public Function PassArray2(ByRef vArray() As String)
'
'msgbox obj.passarray2(ar) 'this fails (still ByRef)
'msgbox obj.passarray2((ar)) 'this fails (forces ByVal)

'Public Function PassArray3(ByRef vArray As Variant)
'
msgbox obj.passarray3(ar)  
msgbox obj.passarray3((ar))

--
Michael Harris

  Hello
          I have a COM component method which requires an Array as an input
  parameter.  I am attempting to call this method from within my VB Script.
  However I get a Type mismatch.  Is their any way to pass an Array to a COM
  component or is it necessary to change the types to Variants.

  All advise appreciated.

  Thanks

  --
  Peter Barber



Fri, 01 Mar 2002 03:00:00 GMT  
 Passing Arrays to COM Components
I didn't have much luck with this until I changed by function signature to
read:

Function ReceiveArray(Arrayname As Variant) as Long
    ReceiveArray = uBound(ArrayName)
End Function

Then the line in the ASP which passes in the array looks like this:

lngReturn = ReceiveArray(ArrayName)

Hope that helps...

Darcy


Quote:
> Hello
>         I have a COM component method which requires an Array as an input
> parameter.  I am attempting to call this method from within my VB Script.
> However I get a Type mismatch.  Is their any way to pass an Array to a COM
> component or is it necessary to change the types to Variants.

> All advise appreciated.

> Thanks

> --
> Peter Barber



Sun, 03 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing array to COM component

2. Passing Variant Array from ASP to COM Component

3. Passing Variant Array from ASP to COM Component

4. Passing optional object arguments from COM components

5. Passing by reference to an ATL COM component

6. pass a COM object reference to a WSC component

7. passing array as parameter to activex component

8. Passing Array of string to component

9. Passing Arrays between ASP/VBScript and ActiveX Components...

10. Passing arrays from ASP To VB-components...need help

11. passing array as parameter to activex component

12. Passing Arrays between ASP/VBScript and ActiveX Components...

 

 
Powered by phpBB® Forum Software