
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