Guest bobba buoy Posted September 24, 2002 Posted September 24, 2002 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. Quote
reboot Posted September 24, 2002 Posted September 24, 2002 It worked fine in vb6. Famous last words. Vb.Net is very different. Show us the code. Quote
Guest bobba buoy Posted September 24, 2002 Posted September 24, 2002 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 Quote
Guest bobba buoy Posted September 24, 2002 Posted September 24, 2002 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. Quote
*Gurus* Derek Stone Posted September 25, 2002 *Gurus* Posted September 25, 2002 You are correct. Once you close the application's main window the message pump stops, effectively closing the program. Quote Posting Guidelines
*Gurus* divil Posted September 25, 2002 *Gurus* Posted September 25, 2002 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. Quote 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 September 25, 2002 Posted September 25, 2002 Thanks! So terminating the project would use Application.Exit() ? Quote
*Gurus* Derek Stone Posted September 25, 2002 *Gurus* Posted September 25, 2002 That's what he said. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.