Groups | Blog | Home
all groups > dotnet interop > november 2007 >

dotnet interop : Accessing VB6 associative array from C#



11/7/2007 9:37:32 AM
I have a legacy VB6 DLL that I'm calling from a C# program. I'm using
the "Add Reference" functionality in VS 2005 to accomplish this.

One of the classes that are implemented in the DLL has a member which
is an associative array (indexed by strings.)

If I call into the DLL from VB.NET, I can use the following syntax and
it works just fine:

myElement = DLLObject.elements("Mine")

....but I can't figure out how to do this from C#. So far I've tried
the following:

myElement = DLLObject.elements["Mine"];

string strIndex = "Mine";
myElement = DLLObject.elements[strIndex];

string strIndex = "Mine";
myElement = DLLObject.elements[ref strIndex];

When I look at the referenced DLL within Visual Studio, about the
closest thing I can find to what I'm looking for is a method:
DLLObject.get_Item(ref Object); - but I'm not sure if this is what I
need to use.

I also see a GetEnumerator() method along with an Add(), but that's
about it.

Is it possible to do this? If so, what would it look like?

Thank you.
japrufrock
12/6/2007 9:32:01 AM
You might try casting the object as a hashtable or using the
CollectionConverter class.

[quoted text, click to view]
AddThis Social Bookmark Button