Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a Visual Basic 6 DLL from VB .NET
DescriptionThis example shows how to use a Visual Basic 6 DLL from VB .NET.
KeywordsVB6, Visual Basic 6, VB.NET, Visual Basic .NET, DLL
CategoriesVB.NET, Software Engineering
 
In Visual Basic 6, create an ActiveX DLL application. Give it a public class with public methods. This are the methods that the Visual Basic .NET application will be able to call.

This example builds a project named VB6Project. It has a public class named MyVB6Class with a public subroutine named VB6SayHi and a public function named VB6ReturnHi.

Compile the project into a DLL.

Next you need to register the DLL. Select the Start menu's Run command and execute the statement:

    regsvr32 VB6Project.dll

Next start a Visual Basic .NET project. Select the Project menu's Add Reference command. Click the COM tab and find the DLL or click the Browse button to select it. Now the .NET application can use the DLL's public classes as shown in the following code.

 
Private Sub btnCallSubroutine_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    btnCallSubroutine.Click
    Dim vb6_class As New VB6Project.MyVB6Class
    vb6_class.VB6SayHi()
End Sub

Private Sub btnCallFunction_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    btnCallFunction.Click
    Dim vb6_class As New VB6Project.MyVB6Class
    MessageBox.Show("Returned: " & vb6_class.VB6ReturnHi())
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated