|Title||Use a VB .NET assembly from Visual Basic 6|
|Description||This example shows how to use a VB .NET assembly from Visual Basic 6.|
|Keywords||VB6, Visual Basic 6, VB.NET, Visual Basic .NET, DLL, assembly|
In the .NET project:
- Select Project\Properties. Open the Configuration Properties folder, select the build tab, and check "Register for COM Interop."
- Set the project's name to something meaningful. E.g. NetTools.
- Add the following in front of the Class statement to expose the class to VB 6:
If you don't do this, the VB 6 program can still use the class but IntelliSense won't know anything about its properties and methods.
In the VB 6 project:
- Select Project\References. Select the DLL. E.g. NetTools.
- Use the Public classes in the DLL.
This works pretty well if you are running VB .NET and VB 6 on the same computer. If you don't build the .NET assembly on the VB 6 computer, you need to perform some extra actions to register it so VB 6 can work with it. See this article on the VB Rad Web site for more instructions and some very insightful discussion.