To show the splash form when the application is loading, whatever method you used to create the form, you need to set a few properties and add a few lines of code.
First, select Project | Properties... Select the General Tab, and change the Startup Object drop down to Sub Main.
Now, select Project | Add Module . Select Module from the list of items. Note, if you already have a module in your project, then you do not need to add a new one.
Then insert the following code into that new module:
Sub Main()
' Show the splash form
frmSplash.Show
' Load the main form
Load frmMain
' Load any other forms you may have that you need
' Show the main form
frmMain.Show
' Remove the splash form from the memory
Unload frmSplash
End Sub
If the splash screen does not appear for long enough, that is because your program is too small! To get round this, you can add a timer to the splash screen so that it will appear for x number of seconds. Add the control, name it tmrShow, set its Interval property to 2000 (2 second) and add the following code to the splash form:
Private Sub tmrShow_Timer()
tmrShow.Enabled = False
ResumeStartup 'resume the startup
Unload Me 'unload the form (hide it)
End Sub
Then, modify the module startup code:
Sub Main()
' Show the splash form
frmSplash.Show 'as the form loads, the timer will start
End Sub
Sub ResumeStartUp()
' Load the main form
Load frmMain
' Load any other forms you may have that you need
' Show the main form
frmMain.Show
End Sub
Comments