Using VB6 Collection objects in VB.NET

  • Thread starter Thread starter ThePinkPanther
  • Start date Start date
T

ThePinkPanther

Guest
I am currently developing an application which uses a third party COM component (written in VB6). The example code in the Third Party documentation states:

Dim oSession as ISession
Dim oDatabase as IDatabase

Set oSession = Connection.Database

For Each oDatabase in oSession

...

Next

However, the oSession which is returned by the Com object is IObject and I get an exception if I try to cast the object to a Collection using CType.

Has anyone come across this before? Ive been scouring google and newsgroups all morning but have been unable to unearth anything.
 
You cant cast a VB6 Collection object into a .NET collection object. It just doesnt work that way. Two entirely different types.
 
Back
Top