As applications scale up and become more complex, the initialize time
often increases before the application displays. This can be a
disadvantage, as the user is left unsure as to whether they have started
the app correctly or if it has failed. Fortunately, this disadvantage can
also be an advantage as it allows the developer to display a splash screen
prior to invoking the main application. This serves two purposes, to alert
the user to wait while the app loads and also to offer the apps name
embedded in flashy graphics, thereby advertising the product and/or the
developer. The simplest way to display a splash screen is to set the
StartUp Object in Project Properties to "Sub Main" and code Sub
Main in a module to call up the splash form, followed by the main app form
as follows: Sub Main()
Dim sngStart As Single
' Display Splash Screen
frmSplash.Show
' Set start time
sngStart = Timer
' Display Splash Screen for 5 seconds
Do While Timer < sngStart + 5
' Yield to other processes
DoEvents
Loop
' Load main form into memory
Load frmMain
End Sub
This subroutine displays the splash screen for a predetermined amount of
time before beginning to load the main app's form. The time delay is
particularly useful if the main app takes a fraction of a second to load
up and offers the user an opportunity to view the splash screen. However, if
the main app itself takes an unacceptable amount of time to load, then
consider removing the time delay as this will only make matters worse.
Next the app's main form is loaded into memory, before the splash screen
is unloaded. This makes for a slick switch over between the splash screen
and the app's main form. The only additional code required is in the app's
main form's Form Load sub as follows:
Private Sub Form_Load()
' add main form initialization code here,
' before Splash Screen handling code
' Remove Splash Screen
Unload frmSplash
' Display app's main form held in memory
Me.Show
End Sub
Now as the main form loads, the splash screen is removed immediately
prior to displaying the main form.
|