locked
FAQ: How do I call/use a VB6 dll in VB.NET application? RRS feed

  • Question

  • How do I call/use a VB6 dll in VB.NET application?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Saturday, April 11, 2009 5:37 AM

Answers

  • Step 1: In Visual Basic 6, create an ActiveX DLL application. Give it a public class with public methods which will be able to be called in the Visual Basic .NET application. Compile the project into a DLL.

     

    This article provides a walkthrough and a demo project.

    http://www.vb-helper.com/howto_net_use_vb6_dll.html

    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.

     

    Step 2: Register the DLL on the target computer.

    Start menu -> Run dialog-> Execute the statement:

    regsvr32 VB6Project.dll

     

    Step 3: Add a reference to this VB6 dll in the VB.NET project.

    Start a Visual Basic .NET project -> Select Project menu -> Add Reference -> Click the COM tab -> Find the DLL or click the Browse button to select it (e.g. VB6Project.dll).

     

    Step 4: The .NET application can now use the DLL's public classes like this:


        Dim vb6_class As New VB6Project.MyVB6Class
        vb6_class.VB6SayHi()
    

     

    For more FAQ about Visual Basic .NET General, please see Visual Basic .NET General FAQ


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Saturday, April 11, 2009 5:39 AM