Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InterOp and shared procedures in VB2005

Status
Not open for further replies.

mmilan

Programmer
Jan 22, 2002
839
0
0
GB
Ok - so we have some DotNet classes that we would like to use from VB6 - not normally a problem, but these classes make use of a few shared methods that we would want to be able to call from VB6.

It seems Shared stuff doesn't get exposed to COM. I just wondered if anyone could walk me through any underlying reason as to why that should be, and suggest any alternative (At the moment, an instanciated wrapper class is the only way forward I can see).

Thanks

Martin
 
Hi mmilan,

Create a new "COM Class" Library project which will create a dll. On the Project Properties Compile tab, choose "Register for COM Interop". This will expose your dll to VB6 and can also be used by .Net too.

In your VB6 project add a reference to the "tlb" file created (.Net projects reference the dll) - easiest way is to browse to the bin folder created when you build your class and you will see the dll and corresponding tlb file.

Any objects you set as shared or public will be visible to your VB6 app, but you need to be careful to make sure that VB6 can use those objects (i.e. be careful about the syntax differences between VB6 and VB2005).

I have found the best way is to do as much processing as you can manage from inside your class and pass values to VB6. You can create VB2005 forms and call them from your VB6 pgm via your COM class.

Take a look at this article which should explain in more detail
Good luck.

Sprowler
 
Thanks for taking the time...

I already have my VB2005 projects exposed to VB6, and callable from VB6... The issue I am looking for information on is whether or not it is possible to expose a Shared Method on a class to VB6.

The IDE seems to suggest not, which might very well be the case - I just want to understand WHY this is the case...

Cheers,


Martin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top