Spalsh screen

Hey dsgreen57 what was the name of that book that had the splash screen code. The link does not work.
 
Another splash screen in VB.NET 2003

Why display a splash screen? In my case, I have to install a second copy of the code for beta testing. My users are doing the test. The customer says to display a splash screen so they know that they started the new beta program instead of the old production code.

I want to display the screen for five seconds but not hold up the program load. I use a sub main in a VB module to start the splash form and the main form. The splash form is a FRIEND so that the main form can close it. At the end of the main form's load event, it subtracts out the time that has already passed and starts a timer with the difference. Here's the code:


Module Main
Friend Splash As New SplashIntro 'Splash Screen
Friend SplashStartTime As Date 'Splash display time

Sub main()
With Splash
.Show()
.Refresh() 'My labels flickered without this refresh
End With
SplashStartTime = Now 'Count 5 seconds from now.
Trace.WriteLine(SplashStartTime.ToLongTimeString)
Application.DoEvents() 'Process event queue

Dim MainProgram As New MainForm
Application.Run(MainProgram) 'Use run so that this form can close Splash
End Sub
End Module


The MainForm has a timer control on the form named "Splashtimer." Here's the code I tacked onto the end of the long form load event:

Trace.Write("Timer interval =")
'We want the splash screen up for 5 seconds. Subtract the time it took
'to get to this point.
Dim TimerInterval As Integer = (5 - DateDiff(DateInterval.Second, SplashStartTime, Now)) * 1000
'Just in case it took too long. Handle errors so they cannot hurt you.
If TimerInterval <= 0 Then TimerInterval = 500 'Should never be true
Trace.WriteLine(TimerInterval.ToString)
With SplashTimer
.Interval = TimerInterval 'Time left for splash screen
.Start() 'Start timer
End With
End Sub


Private Sub SplashTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles SplashTimer.Tick
Trace.WriteLine(Now.ToLongTimeString)
SplashTimer.Stop() 'We only run this once
Splash.Close() 'Close the form
End Sub


The program load takes about two seconds out of the five seconds that the splash screen is displayed. The main program is usable in the other three seconds that the splash is displayed. Hope this helps
 
Back
Top