VB.Net calling Visual Basic 6

I have a VB.net form from which i call a form in a visual basic 6 activeX dll.
.Net requires that i show the visual basic 6 form as modal. This is fine, but when i do this, the vb.net form which called the vb6 form doesnt repaint. So, if the user moves the vb6 form around, the vb.net form underneath looks all screwed up. Does anyone know how to fix this issue?

Thanks
da4thrzaAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
Hi da4thrza;

Try something like this.

    ' Create a variable to hold a thread object
    Private WithEvents BgWorker As New System.ComponentModel.BackgroundWorker

    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        ' Start the thread that will run the VB 6 code
        BgWorker.RunWorkerAsync()

    End Sub

    ' This is where the code is placed that will run in its own thread.
    Private Sub BgWorker_DoWork(ByVal sender As Object, _
        ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BgWorker.DoWork

        Dim oVB6DLL As Object

        oVB6DLL = CreateObject("VB6Project.clsMain")

        ' Because this call is a blocking call the thread will not end until the user
        ' closes the VB 6 form.
        Call oVB6DLL.ShowMe()

        ' Make sure to properly dispose of the object before exiting the thread.

    End Sub

Fernando
0
 
Fernando SotoRetiredCommented:
Hi da4thrza;

You may try to run the VB 6 code in its own thread. This will allow the VB .Net program to respond to paint events. I have not tried this myself but I see no reason why it would not work.

Fernando
0
 
da4thrzaAuthor Commented:
thanks for the response. How do i do that? Is there a way to do that but still call the form as modal?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Fernando SotoRetiredCommented:
What version of VB .Net are you using 2003 or 2005?
0
 
da4thrzaAuthor Commented:
vb.net 2005

i am currently calling the DLL like this:
        Dim oVB6DLL As Object

        oVB6DLL = CreateObject("VB6Project.clsMain")

        Call oVB6DLL.ShowMe()

The show me function calls the main vb6 form as modal

thanks
0
 
Fernando SotoRetiredCommented:
Are there any interactions between the .Net form and the VB 6 code?
0
 
da4thrzaAuthor Commented:
not really. i just need it to launch given some parameters and for the object to be garbage collected once the user closes out of the vb6 form
0
 
da4thrzaAuthor Commented:
Thanks a lot Fernando!
0
 
Fernando SotoRetiredCommented:
I am glad it worked out for you. ;=)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.