Home > Articles > Programming > Visual Basic

Making a Splash

  • Print
  • + Share This
From the author of

Developer Features

Using the splash form is relatively simple. When the program starts, it calls the form's ShowSplash method. ShowSplash returns without waiting for the splash screen to unload so the program can continue with any initialization chores it needs to perform while the splash screen is visible. The example program sets its caption to TestSplash so you can see that it did something while the splash screen was still visible. In a real application, you could connect to databases, load user options from the Registry, and perform other system initialization tasks while the splash screen entertains the user.

Private Sub Form_Load()
  ' Display frmSplash as a splash screen.
  frmSplash.ShowSplash

  ' Initialize the application.
  Caption = "TestSplash"
End Sub

Displaying the form as an about dialog box is even easier. The program simply calls the form's ShowAbout method. ShowAbout displays the splash form modally so control doesn't return to the main program until the user closes the about dialog box.

' Display the splash form as an about dialog.
Private Sub mnuHelpAbout_Click()
  frmSplash.ShowAbout
End Sub

In some applications I have written, I used the splash form for a logon screen instead of a splash screen. To make a logon form, add some labels and text boxes so the user can enter a username and password. Also, add an Ok button.

The form's ShowLogin method should display the form modally much as ShowAbout does. When the user clicks Ok, the form validates the username and password. If the password is correct, the form unloads itself. If the password is wrong, the form presents an error message and doesn't unload, so the user can re-enter the username and password. You may also want to add a Cancel button to the form so the user can give up.

If you build a logon form like this, the form's ShowAbout method should hide the extra logon controls. A user who selects the Help menu's About command doesn't expect to see labels and text boxes for entering a username and password.

  • + Share This
  • 🔖 Save To Your Account