To Create and register the COM object in VB6.0 1.File -> New Project -> ActiveX DLL -> OK 2.Change project name to ComProject. 3.Add class named it as COMClass 4.then in Code Editor Add a Function: Public Function AddingTwoNumbers(num1 As Integer, num2 As Integer) As IntegerAddingTwoNumbers = num1 + num2End Function 5.Save the Project. 6.File -> Make ComProject. Dll Choose the Folder where you want the DLL to be created. Com Interop DLL in VB6 Is created. |
To use a COM object with Visual Basic 2005 1.Open a new Visual Basic Windows Application project. 2.On the Project menu, click Add Reference. 3.In the Browse Tab Go the the Folder you created the DLL and add the ComProject. Dll. Click ok 4.Add the dll using ComProject.dll 5.Add a form and inside form insert a button: on click event call the vb6 function privateĀ void button1_Click(object sender, EventArgs e) { int addresult; TestCOMClass tst = newTestCOMClass(); addresult = tst.AddingTwoNumbers(1, 2); MessageBox.Show(addresult .ToString());
} Now you can able to call the VB6.0 method inside .net |