
Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi,
Nope, collections have nothing to do with my question - I'm talking about
variants.
This is C# code:
ClassInterface(ClassInterfaceType.AutoDual)]
public class TestObject
{
public void SetArray2(ref object ar)
{
// array comes here as int
Debug.WriteLine(ar.GetType().Name);
}
}
This is VBA code:
Call a.SetArray2([1, 2, "str"])
Here's what's output by the C# method during debugging:
Int32
Here's the value of the argument (ar):
{-2146826273}
[System.Int32]: {-2146826273}

Signature
Best regards,
Ruslan Popov
"Peter Huang" [MSFT] - 16 Nov 2005 11:30 GMT
Hi
I think you may to use the Array in VBA.
Sub Test()
Dim o As New ExposeSafeArray.TestClass
Dim r As Variant
r = Array(1, 2, "Test")
Call o.MyMethod(r)
End Sub
public void MyMethod(ref object param)
{
try
{
object[] obs=(object[])param;
for(int i=0;i<=obs.GetUpperBound(0);i++)
Debug.WriteLine(obs[i].ToString());
}
catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Ruslan Popov - 16 Nov 2005 13:08 GMT
You are right, Peter. Thanks. :)

Signature
Best regards,
Ruslan Popov
"Peter Huang" [MSFT] - 17 Nov 2005 02:37 GMT
Hi
You are welcomed!
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.