papa_k Posted August 15, 2003 Posted August 15, 2003 Hi. I have come across some problems with .Net which im sure are simple to fix if you have even just an ounce more knowledge than me... (the .net book i have is crap and doesn't help with these simple problems) Firstly i wish to start the application with a splash screen followed by a login screen. once login has been authenticated, the app will go into a main menu screen. what is the best way to do this? when i first attempted it i opened up the splash screen, then the login screen, but closed the splash screen (no longer needed) which then inturn closed the login screen and the app. Probably (if not def.) because i called the login screen within the splash screen. as soon as the splash screen was closed variables (class forms) within the splash screen then close, and the app then shuts off. so i read that i could create a sub main which would all the splash screen, then the login screen and so on. I did this and it worked. I'd set the project start up to be the sub main. but since i did that i thought that the module would have to be called somethin else, liks startup. as its only run once with the aim to load the splash screen and login form. everything else can be run using the class methods and opening forms from within forms (from main screen onwards). i renamed the sub (to sratup) but couldnt find it in the options to use it as a start up object. i then deleted the renamed item and created a new one again with the needed information to open the splash screen and login screen. i cant find the new sub in the object start up menu, sub startup, but the flaming sub main is stil there (which i have infact deleted and is to all intense and purpose not part of the project anymore). what have or am i doing wrong. if you have questions, or cant understand what i am getting at please reply and say what is up. VB6 i know, .net i am very new with and im strugerling because it seems to wanna be helpful but it just seems to over complicate things (especially when you change your mind). i am a patient person - this is the second attempt at using .net - i know its probably the way forwards but i still need to be convinced. Please help. Cheers, Papa. Quote without time nothing ever ends
*Gurus* divil Posted August 15, 2003 *Gurus* Posted August 15, 2003 Create yourself a Sub Main, and run two separate message loops, one for the lifetime of your splash form (which should have a timer on to Close itself) and then one for your main application. Dim splash As New frmSplash() Application.Run(splash) Dim mainForm As New frmMain() Application.Run(mainForm) 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
papa_k Posted August 15, 2003 Author Posted August 15, 2003 Create yourself a Sub Main, and run two separate message loops, one for the lifetime of your splash form (which should have a timer on to Close itself) and then one for your main application. Dim splash As New frmSplash() Application.Run(splash) Dim mainForm As New frmMain() Application.Run(mainForm) thanks for this. i have done what you said. i have created a module and called it Sub Main. This is set as the start up object for the project... BUT... I get two errors... 'Sub Main' was not found in testProj' ...and for this code... Module Sub_Main Dim test As New frmMain() Application.run(test) End Module i get this error... Declaration Expected What am i doing wrong? Quote without time nothing ever ends
*Gurus* divil Posted August 15, 2003 *Gurus* Posted August 15, 2003 That isn't a Sub Main, that's a module called Sub_Main. Set your startup object to Sub Main, and then create yourself a new class that looks something like this: Friend Class MainClass Public Shared Sub Main() 'Insert the code I gave you earlier End Sub End Class 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
papa_k Posted August 15, 2003 Author Posted August 15, 2003 That isn't a Sub Main, that's a module called Sub_Main. Set your startup object to Sub Main, and then create yourself a new class that looks something like this: Friend Class MainClass Public Shared Sub Main() 'Insert the code I gave you earlier End Sub End Class thanks divil. sorry for being a fool - as i said new to, 'bit of a school boy error' though... d'oh. thanks again. Papa. Quote without time nothing ever ends
papa_k Posted August 15, 2003 Author Posted August 15, 2003 sorry about this - i get the same problem as before. i have tried to sort this out on my own, but i cant the splash screen appears - i close it (or the timer shuts it) and then the main form appears and then disappears. heres the code from main. what the hell am i missing. i have a msgbox that pops up in the main form load statement (yes, it does appear) Friend Class MainClass Public Shared Sub Main() Dim formSplash As New frmSplash() Application.Run(formSplash) Dim formMain As New frmMain() Application.Run(formMain) End Sub End Class Quote without time nothing ever ends
*Experts* mutant Posted August 15, 2003 *Experts* Posted August 15, 2003 It shouldnt disappear, do you have any code in Load event that could cause it to close? Quote
papa_k Posted August 15, 2003 Author Posted August 15, 2003 Public Class frmMain Inherits System.Windows.Forms.Form - Windows Form Designer Code Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load MsgBox("this") Me.Show() End Sub End Class is what is in the form. Quote without time nothing ever ends
*Gurus* divil Posted August 15, 2003 *Gurus* Posted August 15, 2003 Are you disposing of the splash form property? In the timer event, it might be worth disabling the timer before calling Me.Close() and me.Dispose() 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
papa_k Posted August 15, 2003 Author Posted August 15, 2003 a review of the problem this is the code: Dim formSplash As New frmSplash() Application.Run(formSplash) Dim formLogin As New frmLogin() formLogin.Show() this is what happends: ----------------------------------- sub main starts the form splash is intialised the form splash is shown the form splash closes the form main is intialised the form main is shown the sub main reaches end sub the application ends. ----------------------------------- people must have carried out a similar way of starting an application, and yet i have not had any real solutions to the problem. it appears that the app. is reaching the end sub and exiting, but it doesnt do this if i only have: Dim formMain As New frmMain() Application.Run(formMain) Quote without time nothing ever ends
papa_k Posted August 15, 2003 Author Posted August 15, 2003 Are you disposing of the splash form property? In the timer event, it might be worth disabling the timer before calling Me.Close() and me.Dispose() how do i do this? disable the timer... i have a me.close() in the timer event Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Me.Close() End Sub Quote without time nothing ever ends
*Gurus* divil Posted August 16, 2003 *Gurus* Posted August 16, 2003 myTimer.Enabled = False 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
papa_k Posted August 18, 2003 Author Posted August 18, 2003 example? please could someone post a example vb.net app zip file with a simple application that shows a splash screen frmSplash loads a login screen frmLogin if you enter 'testdrive' as a user name and 'keys' as the password it then opens a main frmMain else does nothing. i cant get my app to work and i am very very frustrated!!! i know i should be able to get this to work, but i just cant! :( - papa Quote without time nothing ever ends
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.