Splash Screen and Timer

MarkBad311

New member
Joined
Oct 20, 2006
Messages
1
Location
Erie Pennsylvania
Programming Experience
1-3
I have been programing VB for some time now and I have done this in VB6 but I am using visual Studio now.

My Problem is I have a Splash screen and after a timers tick event I would like it to unload the splash screen and load the Main Form. I can't use .Hide because the tick event repeats and also the application doesn't close properly.

So to recap I have a splash screen and I want to load the main form and unload the splash form on the tick event. Here's the code that doesn't do what I want it to do

VB.NET:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim myForm As New frmMain
        Timer1.Enabled = False
        myForm.Show()
        Me.Close()
    End Sub


Me.Close closes the whole project. not just the intro form
 
Will this work?

PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Timer1.Interval = 1000
Timer1.Enabled = True
EndSub
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim myForm AsNew Form
Timer1.Enabled = False
myForm.Show()
Me.Visible = False
EndSub

If you use this you will want to make sure you destroy any objects (controls) on the main form so they don't use any more RAM than necessary.
 
Last edited:
All you need is a Timer in the splash screen with "Me.Close()" in the Tick event handler. You then start your application from a Main method that looks like this:
VB.NET:
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New SplashForm)
Application.Run(New MainForm)
That's it. The Main method will be used as the entry point for the app. After enabling visual styles it will display a splash screen. That will sit there until the Timer Ticks, at which pojnt it will close itself. Control then retruns to the Main method, which displays your main form. The user then does what they do and when they close the main form control will return to the Main method, which then completes and the app exits.
 
Back
Top