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
vikasbapatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
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.
vikasbapatAuthor Commented:
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 ?

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
You could try Activate() or BringToFront()...or some combo of them:

        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

        Me.BringToFront()
        Me.Activate()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
If that doesn't work then we need to use some WinAPIs instead...
vikasbapatAuthor Commented:
Hi,

It worked..

Thanx a lot.

vikasbapatAuthor Commented:
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 ?
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.