kaisersoze Posted May 11, 2004 Posted May 11, 2004 developing windows base app in vb.net I have a sub main in a module and sub main is activated first to do some initial settings, then it should load frmMainMenu. No run time errors but, during running the app. the form is loaded only for few seconds and the app. closes by itself. Here is the code: vdbAccess = New dbAccess If vdbAccess.TestDatabaseConnection(gblConStr) = False Then MsgBox("error in database connection") End End If Dim objMainMenu As New MainMenu objMainMenu.Show() objMainMenu.Activate() ---------------------------- Quote Note: I think as a programmer not as a human, so use my answer at your will
Administrators PlausiblyDamp Posted May 11, 2004 Administrators Posted May 11, 2004 Before the end of Sub Main you need to do something like application.Run(objMainMenu) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted May 12, 2004 Posted May 12, 2004 Just to give you the right code... vdbAccess = New dbAccess If vdbAccess.TestDatabaseConnection(gblConStr) = False Then MsgBox("error in database connection") End End If Dim objMainMenu As New MainMenu Application.Run(objMainMenu) 'The code placed here will only run when you close the application... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Arch4ngel Posted May 12, 2004 Posted May 12, 2004 Why it's happening ? Because when you "Show" your main menu... it'll process the other line afting showing it. And when a program reach the end of the "Main"... it close by itself. Application.Run(objMainMenu) make your application go in a listening loop (for events, etc. ) so your application don't close immediatly. /** Was only additional information **/ Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
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.