News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

Example Code For Visual Basic 6 DLL in Vb.net

Started by nandagopal, Nov 29, 2008, 10:16 PM

Previous topic - Next topic

nandagopal

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