Wednesday, June 04, 2008

Use VB.NET user control as Active X (ocx) control in VB6

Writing post after long time. This seems to be a very common problem. When you are having a existing VB6 application that is going to be upgrading to VB.NET application but you need to go step by step. So most of new development is done using VB.NET and then you integrate that your VB6 application. There are two scenarios here:
1. You write business logic/data layer in VB.NET which is basically a ".dll" file. This file you can use in your VB6 code by using "regasm" for registering the DLL and creating "Type Library". Add this as reference to your project and use classes/methods and properties in your VB6 code.

2. You develop a user control or form in VB.NET and now you want to use in VB6. Now here lies the problem, VB6 only knows .OCX extensions for user control, it doesn't understand ".dll" extension for user controls. While searching on how this can be done without to much of effort I came across a really nice and easy solutions to this problem.

Interop Forms Toolkit provides solution for building VB.NET forms, controls and then using it easily in your VB6 code. It provides with excellent help on how to use the toolkit. Only thing what I found difficult was "How to deploy the application?"
Though there is help provided for that, I had lot of problems while deploying the application. I'll research more on this and will get back in my next post as in what are easy ways to deploy the application using this tool.