Dll from VB.NET to VB 6.0

Dll from VB.NET to VB 6.0

Post by Q2FybG9zIF » Thu, 10 Nov 2005 00:57:19


I'm trying to use a dll developed from VB.NET 2003 to a VB 6.0 project. I can
add a reference to the project but I can't access the methods of the class
inside of dll. Somebody could show me a way to access the methods from my dll?

Thank's

Carlos
 
 
 

Dll from VB.NET to VB 6.0

Post by Brian Mut » Thu, 10 Nov 2005 01:26:13

You need to build a COM Interop. This should be covered in your VB.NET 2003
reference book.

Brian

"Carlos Voltolini" < XXXX@XXXXX.COM > wrote in

 
 
 

Dll from VB.NET to VB 6.0

Post by Q2FybG9zIF » Thu, 10 Nov 2005 02:48:08

I'm sorry but I don't find a way to resolve this problem. I do every steep
but I don't can access the methods

Thank
 
 
 

Dll from VB.NET to VB 6.0

Post by Brian Mut » Thu, 10 Nov 2005 04:03:37

Did you build a COM interop like I suggested? If so, why not post some code
so that we can take a look...

Brian
 
 
 

Dll from VB.NET to VB 6.0

Post by Q2FybG9zIF » Thu, 10 Nov 2005 04:48:29

This is my VB.NET code

Public Class UserControl1

Public Function Test(ByVal Vlrr As Integer) As Integer
Test = Vlr * 2
End Function
End Class

-----

So I added a reference in vb 6 project, and this is my code in vb6

Dim Obj as New MyDLL.UserControl1
Obj = CreateObject("MyDLL.UserControl1")

When I compile the project, the VB debug stop and show this error "ActiveX
can not create object"

:/

Carlos
 
 
 

Dll from VB.NET to VB 6.0

Post by Brian Mut » Thu, 10 Nov 2005 07:38:58

I'm assuming you successfully ran regasm xxxx.dll /tlb:xxxx.tlb.

You left out the "Set" keyword in front of Obj. Try changing to:

Dim Obj as MyDLL.UserControl1
Set Obj = New MyDLL.UserControl

Make sure the assembly and the tlb is in the same directory as the VB
executable if you haven't registered it in the GAC. This should get you a
little further.

Brian