wjensen
February 16th, 2000, 10:38 PM
I am trying to pass a VARIANT array of strings from a VB class to a method in a control written in C++. At run time I get a runtime error 5, invalid procedure call or argument. The method is present, and the .dll containing it is the only one registered (or present at all) on the machine. It shows up in the object browser too. Any help on this would be appreciated.
My method is declared in C++ as follows:
.idl
[id(1), helpstring("method MyMethod")] HRESULT MyMethod([in]VARIANT Filenames, [out, retval]long * result);
.h
STDMETHOD(MyMethod)(/*[in]*/VARIANT Filenames, /*[out, retval]*/long * result);
And I access it as follows in VB:
Dim oMyObject as new MyObject
Dim szStrings() As String
Dim vArray as Variant
Dim lReturn as Long
ReDim szStrings(3)
szStrings(0) = "One"
szStrings(1) = "Two"
szStrings(2) = "Three"
vArray = szStrings()
'And here I get an error
lReturn = oMyObject.MyMethod(vArray)
My method is declared in C++ as follows:
.idl
[id(1), helpstring("method MyMethod")] HRESULT MyMethod([in]VARIANT Filenames, [out, retval]long * result);
.h
STDMETHOD(MyMethod)(/*[in]*/VARIANT Filenames, /*[out, retval]*/long * result);
And I access it as follows in VB:
Dim oMyObject as new MyObject
Dim szStrings() As String
Dim vArray as Variant
Dim lReturn as Long
ReDim szStrings(3)
szStrings(0) = "One"
szStrings(1) = "Two"
szStrings(2) = "Three"
vArray = szStrings()
'And here I get an error
lReturn = oMyObject.MyMethod(vArray)