473,466 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Coomunicatioin between .Net and VB6 Apps

Hi,

I have an existing VB6 application that I intend to add some additional
functionality to. This app will be eventually converted to .NET but probably
not in the near future. The new functionality will not have a really close
dependency on the exiting application other than sharing a common database.
One option that I have been considering is to build the new functionality
into a VB.Net application. It is likely that I will use a standard EXE or an
ActiveX.Exe in VB6 because the existing application is MDI and I also need a
new MDI window for the new functionality.

So here is my question. I am looking for a simple way to establish two way
communications between the two applications. I would like to avoid using the
SendMessage function if possible so that the communications has room to
grow. In the first instance this is what I would like to do:
1. Start the .NET application from the VB6 or activate it if it is running.
2. Provide it with some start up data.
3. Optionally hide or leave the VB6 application running when the .Net
application is running.
3. Activate or close the VB6 application when the .Net application closes

Ideally I would also like to raise events (or otherwise send messages) from
the .Net application to the VB6 application. Can anyone point me in the
right direction on the best tools I can use to implement this? In VB6 I
would almost certainly implement the new application as an ActiveX server.
So I guess I am looking for a replacement for this in a combined COM and
..Net world.

Thanks.
Nov 20 '05 #1
4 1518
This is what Interop is all about.

Make your new VB.Net app and give it events you want ot expose to the VB6
app, add COM GUIDs, compile and build a type library.

declare the tlb in your vb6 app WithEvents and you can code against those
events (and all of the Public objects and interfaces) ... there's your
communication.

Pick up the Lhotka & Hollis book on Iterop:

http://www.amazon.com/exec/obidos/tg...books&n=507846

It was on WROX but you should still be able to find it at bigger bookstores.

You'll find it all falls into place very simply ... wait till you get into
using autodeploy on those vb7 applets you're calling from VB6! (And then
when you make all of those autodeployed applets use remoting!) That's when
this stuff gets fun to code :)

-smith
kirkland, wa
Nov 20 '05 #2
That is very good information. One of the reasons I was looking at an
ActiveX.Exe in VB6 is that it allowed both the old and the new application
to use an MDI. When I put together a quick pair of test applications I found
that both the client VB6 and the server .Net application could show MDI
windows. This is great if there are no adverse side effects (and the only
reason that I think there might be is because you can't add one to a VB6
dll.

In my test I couldn't declare the .Net component WithEvents but I guess the
technique for doing this must be included in Professional Visual Basic
Interopability that you recommended and that I will get hold of

Thanks again.

"smith" <rc********@smithvoiceTAKEOUT.com> wrote in message
news:Ds*****************@newsread2.news.pas.earthl ink.net...
This is what Interop is all about.

Make your new VB.Net app and give it events you want ot expose to the VB6
app, add COM GUIDs, compile and build a type library.

declare the tlb in your vb6 app WithEvents and you can code against those
events (and all of the Public objects and interfaces) ... there's your
communication.

Pick up the Lhotka & Hollis book on Iterop:

http://www.amazon.com/exec/obidos/tg...books&n=507846
It was on WROX but you should still be able to find it at bigger bookstores.
You'll find it all falls into place very simply ... wait till you get into
using autodeploy on those vb7 applets you're calling from VB6! (And then
when you make all of those autodeployed applets use remoting!) That's when this stuff gets fun to code :)

-smith
kirkland, wa

Nov 20 '05 #3
Hi Martin,

Here I write a sample about how to expose the event of .NET component to
VB6.
[TestComObject.Class1]
Imports System.Runtime.InteropServices
Public Delegate Sub testdelegate()
<GuidAttribute("1F98211C-7A71-4588-8D4A-AD85CA80BAE7"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)> _
Public Interface ControlEvents
<DispIdAttribute(1)> _
Sub testevent()
End Interface
<ComSourceInterfaces(GetType(ControlEvents)),
ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class Class1
Dim WithEvents fm As Form1
Public Sub test()
fm = New Form1
fm.Show()
End Sub
Public Event testevent()
Private Sub fm_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles fm.Closed
RaiseEvent testevent()
End Sub
End Class
[VB6 code]
Dim WithEvents o As TestComObject.Class1
Private Sub Command1_Click()
Set o = New TestComObject.Class1
o.test
End Sub
Private Sub o_testevent()
MsgBox "event fired"
End Sub

HOW TO: Sink Managed Visual Basic .NET Events in Internet Explorer Script
http://support.microsoft.com/?kbid=316516

Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconexposingnetframeworkcomponentstocom.asp

If you have any concern please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4
Hi Peter,

That sample is great and the links are very useful too. This gives me the
foundation to perform all the processing I will need to do in the first
instance. I thought I would need to wait until I got some more reference
material but I now have everything I need to get going. Thanks

Martin
"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:Ns**************@cpmsftngxa07.phx.gbl...
Hi Martin,

Here I write a sample about how to expose the event of .NET component to
VB6.
[TestComObject.Class1]
Imports System.Runtime.InteropServices
Public Delegate Sub testdelegate()
<GuidAttribute("1F98211C-7A71-4588-8D4A-AD85CA80BAE7"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)> _
Public Interface ControlEvents
<DispIdAttribute(1)> _
Sub testevent()
End Interface
<ComSourceInterfaces(GetType(ControlEvents)),
ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class Class1
Dim WithEvents fm As Form1
Public Sub test()
fm = New Form1
fm.Show()
End Sub
Public Event testevent()
Private Sub fm_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles fm.Closed
RaiseEvent testevent()
End Sub
End Class
[VB6 code]
Dim WithEvents o As TestComObject.Class1
Private Sub Command1_Click()
Set o = New TestComObject.Class1
o.test
End Sub
Private Sub o_testevent()
MsgBox "event fired"
End Sub

HOW TO: Sink Managed Visual Basic .NET Events in Internet Explorer Script
http://support.microsoft.com/?kbid=316516

Exposing .NET Framework Components to COM
http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconexposingnetframeworkcomponentstocom.asp

If you have any concern please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ted Gill | last post by:
Platform: Windows ME Python version: 2.3.2-1 Problem: Running GUI apps in Idle does not work. When executing GUI (tkinter/pmw) apps from the edit windows or doing an "import <file>" in the...
14
by: mirnazim | last post by:
Hi, There are great Python Web Application Framework. But most of them are meant for content oriented web apps. Is there something that can ease the development of application that are not...
2
by: Richard Choate | last post by:
I'm writing an article and I need your informed opinions, so I ask you this: 1. Doesn't the web-enabled app generally run slower for one reason or another? 2. Isn't the fact that application...
0
by: Glenn Engelbart | last post by:
I am trying to find out a way to get more code re-use & object orientation in the UI portion of my apps. (There already is plenty of both in the DataAccess & Business Logic portion of my apps. ...
3
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net...
4
by: Jeff | last post by:
We have multiple ASP.Net web apps in development. As a standard we are looking to go with SQL Server to hold state information. Can we have the multiple apps all point to a single State DB? Or...
25
by: mad NAT'er | last post by:
Can any one give me a few examples of commercially available apps written in C#?
9
by: TC | last post by:
Like a lot of database developers, I often choose Jet for the back- end. I'm starting to worry about what will happen when Jet is deprecated. Ostensibly, Jet users like me must switch to SQL Server...
3
by: lds | last post by:
On our server we have both applications that have been migrated to use v2.0 of the framework as well as apps that have not yet been migrated and still use 1.1. When I tried to deploy my v2.0 app...
13
by: John | last post by:
Hi How can I send simple messages/command like "GotoClientRecord=1024" or "GotoSupplierRecord=234" from a vb.net app to a) a vb.net winform app and b) an MS Access app, all three running on the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.