Splash Screens

Showing it

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

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“God could create the world in six days because he didn't have to make it compatible with the previous version.”