Showing posts with label object not defined. Show all posts
Showing posts with label object not defined. Show all posts

Monday, January 16, 2017

Return object from VB.net to VB6 (Object not defined)

Hi,

I was working on a project where there was a change needed in VB6 application.
This change was implemented in VB.net but there were few things involved in returning values from .net to VB6 which caused little challenge.
Without realizing, I thought that the class object I m creating in .net would be understood by VB6 but, I was wrong.

I was keep getting error when I was calling .net function in VB6 that was returning object in vb.net.
The error was "object not defined".

To fix this problem, what I did, I decomposed my single class into 2 classes; say ClassA and ClassB.
Then I created objects of each class in VB6 and then used properties to pass values from ClassA object to ClassB.

In the constructor of ClassA, I initialized the property which was ReadOnly property in my class.
Then I passed this property by assigning to ClassB object's property.

What I was doing wrong returning ClassB object from .net function to VB6 which wasn't working. So  I guess the correct way to create separate classes and objects and then pass values between them using properties.

HTH.