Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how can i Access a Visual Basic ActiveX DLL from Visual C++?

blueeyesblueblueeyesblue Member Posts: 10
I can make a ActiveX DLL by VB6, which can be loaded in VC.NET or VC6. But I cant make a correct DLL in VB.NET. Everytime I loaded it into VC.NET or VC6, it said that "No type library found in file:...ClassLibrary1.dll".

*****************************************************************
ActiveX dll in VB6
Create a Visual Basic ActiveX DLL project. Class1 is created by default.
Add the following code to Class1:
Public Function MyVBFunction(x As Integer) As Integer
MsgBox x
End Function

Compile the DLL as c:Project1.dll and exit Visual Basic.
*****************************************************************
the job in vc
Click Edit Code to bring up the code for BOOL CTst1App::InitInstance(),
find the line AfxEnableControlContainer();,
and add the following line before it:
AfxOleInit();

Open .cpp, scroll to the bottom to theCAboutDlg::OnOK(),
and replace it with the following code:

void CMyAppDlg::OnOK()
{
short st = 2;
short st1;
_Class1 p;
p.CreateDispatch("Project1.Class1");
st1 = p.MyVBFunction(&st);
CDialog::OnOK();
}

*****************************************************************


the same code as the vb6 above in my VB.NET

Option Explicit On
Public Class Class1
Public Function MyVBFunction(x As Integer) As Integer
MsgBox x
End Function
End Class

******************************************************************
blueeyesblue
Sign In or Register to comment.