How to access values from VBA.CollectionClass

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saheli
    New Member
    • Feb 2008
    • 1

    How to access values from VBA.CollectionClass

    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.CollectionC lass.

    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.CollectionC lass to VisualBasic.Col lection is also throwing exception while if i do not typecast it i am gettting System_ComObjec ts from where i have no clue of the actual values present in the collection.(can not fetch the acual values present in the inner collection)

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

    where mWinJob is the object of the VB class and GetDataCollecti on() 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.ToInt3 2(i) - 1))
    {
    col= (Collection)dat aCollection.Ite m(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
Working...