Jump to content
Xtreme .Net Talk

Migrating Multi-Form vb6


Recommended Posts

Guest bobba buoy
Posted
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.
Guest bobba buoy
Posted

Funny you should mention that. I had that very thought as I typed it.

 

Here is the code behind the forms

 

  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

Module Module1
   Public Sub Main_Renamed()
       Form1.DefInstance.Show()
   End Sub
End Module

Guest bobba buoy
Posted
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.
  • *Gurus*
Posted
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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest bobba buoy
Posted
Thanks! So terminating the project would use Application.Exit() ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...