Migrating Multi-Form vb6

  • Thread starter Thread starter bobba buoy
  • Start date Start date
B

bobba buoy

Guest
I wrote a simple vb6 app to get the feel of .Net structure. I all works fine except I can't change forms. It migrated with no errors/warnings but when I select the button that Unloads one form and loads the other, the second form loads very briefly and then the app ends. Any help? It worked fine in vb6.
 
Funny you should mention that. I had that very thought as I typed it.

Here is the code behind the forms

Visual Basic:
   Private Sub Command1_Click(ByVal eventSender As 
         System.Object, ByVal eventArgs As System.EventArgs) 
        Handles Command1.Click
        Dim strYesNo As String
        strYesNo = CStr(MsgBox("Are you sure?", MsgBoxStyle.YesNo, "Confirm"))
        If strYesNo = CStr(MsgBoxResult.Yes) Then
            End
        End If
    End Sub

    Private Sub Command2_Click(ByVal eventSender As     
               System.Object, ByVal eventArgs As System.EventArgs) 
              Handles Command2.Click
        Me.Close()
        Form2.DefInstance.Show()
    End Sub

And here is the code behind the module
Visual Basic:
Module Module1
    Public Sub Main_Renamed()
        Form1.DefInstance.Show()
    End Sub
End Module
 
I think I answered my own question. If you unload the form the start-up form/module in .Net the program terminates? When I change Me.Close to Me.Hide, it works fine. FYI. And if I'm wrong on this, please tell me.
 
If you don't want your application to rely on one "main window" you can always start a message pump off using Application.Run() (note you're not passing a form) and then use Application.Exit() to finish that message pump when you're done.
 
Back
Top