Connecting Tech Pros Worldwide Help | Site Map

How to access values from VBA.CollectionClass

Newbie
 
Join Date: Feb 2008
Posts: 1
#1: Feb 13 '08
In my C# project i call a VB 6.0 .dll which in turn returns
a load of information. Most of this information is readable. However,
some of the information returned is of type VBA.CollectionClass.

Actually the VB function returns collection of collection.
(A colection that in turn stores many collection objects).

I am able to get back the Collection returned from VB but is unable to get the values from the collection that is present in this collection returned.

Type casting the VBA.CollectionClass to VisualBasic.Collection is also throwing exception while if i do not typecast it i am gettting System_ComObjects from where i have no clue of the actual values present in the collection.(cannot fetch the acual values present in the inner collection)

My code is:
VBA.Collection dataCollection= mWinJob.GetDataCollection();

where mWinJob is the object of the VB class and GetDataCollection() is the method that returns VBA.Collection object(this VBA.Collection in turn contains VBA.Collection objects)


Collection col =new Collection();
for (i = dataCollection.Count(); Convert.ToInt32(i) >= 1; i = (Convert.ToInt32(i) - 1))
{
col= (Collection)dataCollection.Item(ref i);//throws exception
}

dataCollection.Count() returns correct value.

Idea is that I want to iterate through the main collection returned from the VB method and then get each collection in the col variable. And then access each data from the collection.

Any idea how to do this?Any one knowing please help....This is urgent
Reply