S
Scott M. Lyon
I'm working on using the COM Interop wrapper on an existing .NET library, to
allow existing VB6 applications to call the .NET code.
And I've been able to get it working in a basic sense (I can return basic
types like strings and booleans, and I've added a reference to MSCORLIB.tlb
so I can even return Hashtables, which the .NET library uses quite a bit).
However, I cannot figure out how to work with the Hashtable objects from
VB6.
Here's an example. I have a .NET function called GetProjects() that returns
a Hashtable of Project objects. The Project object is one that we defined,
and has a variety of methods and properties. All I need for the moment is
the .Name property (which returns a string).
I'd like to get the Hashtable, and simply loop through the objects contained
therein, and display the Project.Name property for each.
I was thinking something along the lines of:
Dim aLibrary As New NETLibrary ' This is my .Net library that I'm trying
to call from VB6
Dim aHash As New Hashtable
Dim aProject As Project
Set aHash = aLibrary.GetProjects
For Each aProject in aHash
Debug.Print aProject.Name
Next
Unfortunately, VB6 isn't liking that "for each" syntax. But I'm at a loss to
figure out how to do this otherwise.
Can anyone offer suggestions?
Thanks!
allow existing VB6 applications to call the .NET code.
And I've been able to get it working in a basic sense (I can return basic
types like strings and booleans, and I've added a reference to MSCORLIB.tlb
so I can even return Hashtables, which the .NET library uses quite a bit).
However, I cannot figure out how to work with the Hashtable objects from
VB6.
Here's an example. I have a .NET function called GetProjects() that returns
a Hashtable of Project objects. The Project object is one that we defined,
and has a variety of methods and properties. All I need for the moment is
the .Name property (which returns a string).
I'd like to get the Hashtable, and simply loop through the objects contained
therein, and display the Project.Name property for each.
I was thinking something along the lines of:
Dim aLibrary As New NETLibrary ' This is my .Net library that I'm trying
to call from VB6
Dim aHash As New Hashtable
Dim aProject As Project
Set aHash = aLibrary.GetProjects
For Each aProject in aHash
Debug.Print aProject.Name
Next
Unfortunately, VB6 isn't liking that "for each" syntax. But I'm at a loss to
figure out how to do this otherwise.
Can anyone offer suggestions?
Thanks!