Link to home
Start Free TrialLog in
Avatar of vikasbapat
vikasbapat

asked on

Calling VB 6 Exe from VB.Net

Hi,

 I have a appliation which is developed in VB6. I am in process of upgrading it to VB.NET. ( and adding new forms to VB.NET Also ).

Right Now my both exes ( VB6 and .NET ) are required for complete functionality. So what I have done for a single user interface,  is ,

1. I have changed VB6 exe to accept command line parameters.
2. I call the VB6 exe with required formname as parameter from VB.NET
3. In VB6, I check for command line parameter and show the form based on it.

Everything is working ok. except, I cannot show the VB6 Forms in VB.NET as Modal Forms in my MDI. ( So my users do not like it.. )

Is there any way out ? Please Help.

Rahul
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You can disable your main Mdi Form until the VB6 exe exits.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Enabled = False

        Dim p As Process = Process.Start("c:\someFile.exe")
        While Not p.HasExited
            System.Threading.Thread.Sleep(100)
            Application.DoEvents()
        End While

        Me.Enabled = True
    End Sub

You can trap the exe's exit code if necessary for decision branching.
Avatar of vikasbapat
vikasbapat

ASKER

Hi Idle_Mind,

Thanx a lot..

Everything worked except 1 thing...  After User exit's the VB  Form, control does not goes to the MDI Application.

Any clues ?

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If that doesn't work then we need to use some WinAPIs instead...
Hi,

It worked..

Thanx a lot.

Hi Idle_Mind,

Now I have a problem that :

When I open  VB application and switch to another one (any other folder currently open) it dont allow  me to work with the VB appl ,i have to close that it Ctrl+Altr+Delete.

Any clues ?
Well...yeah, if the form is disabled you can't work with it can ya?

Another option would be to disable all the controls themselves (instead of the whole form as we did before).

     Button1.Enabled = False
     Button2.Enabled = False
     ' etc...

     ' ...code...

     Button2.Enabled = True
     Button1.Enabled = True