Passing String Arrays between VB.Net and VB6

We have a (very) large VB6 application. I'm in the process of extending it and gradualy replacing parts of it with VB.Net modules. I'm writing DLLs in VB.Net and using COM interop to consume them in the VB6 app. This is working great! We are in the business of migrating (very large) COBOL systems and I get a kick out of how VB6 is now a 'legacy' framework in itself.

Any way, here's my current problem: how do I pass a string array from the VB.Net DLL to a VB6 consumer. What I want is declaration like so:

Public function SomeFunction(Byval StringArray() as String) as boolean


I've looked at Default Marshaling for Arrays, but could not make heads or tails from it...

So I guess I'm looking for the recepie for String Arrrays in a VB.Net DLL that will be exposed by COM interop.

Thanks,
Gil


Answer this question

Passing String Arrays between VB.Net and VB6

  • Mowali

    Thanks Lucian, I don't know why it did not work for me before.

  • pauleley

    A string[] in .net is marshaled as [in] SAFEARRAY(BSTR) strings on the COM side which I believe is the same as [ Byval StringArray() as String ]. I'm not into VB, so I'm not sure, but it seems reasonable.
  • Passing String Arrays between VB.Net and VB6