Winform Splash Screen - VB.NET - Timer
I would suggest using the built in Splash Screen that is provided by Visual Studio:
Go to the "Projects" menu and select "Add Windows Form" and select the Splash Screen template:
Then in the Project's Application settings, select that form to be the Splash screen:
Your start up form should be your login form, not the splash screen form.
Update:
Click on the "View Application Events" button on the last image from your My Project's Application screen and add this code to set the MinimumSplashScreenDisplayTime value:
Imports System.Collections.ObjectModel
Namespace My
Partial Friend Class MyApplication
Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
Me.MinimumSplashScreenDisplayTime = 5000
Return MyBase.OnInitialize(commandLineArgs)
End Function
End Class
End Namespace
Your splash screen will remain on the screen for 5000 milliseconds, or 5 seconds.
Try adding a Module to your program with a Public Sub Main
Method. Set your project Startup options to Sub Main. You can then do something like:
Module Module1
Dim frmSplash As SplashScreen1
Dim frmLogin As Login
Dim frmMain As MainMenu
Dim splashTimer As Timer
Public Sub Main()
splashTimer = New Timer()
AddHandler splashTimer.Tick, AddressOf TimerTick
splashTimer.Interval = 5000
splashTimer.Start()
frmSplash = New SplashScreen1
frmSplash.ShowDialog()
frmLogin = New Login
Dim result As DialogResult = frmLogin.ShowDialog
If result <> DialogResult.OK Then
End
End If
frmMain = New MainMenu
frmMain.ShowDialog()
End Sub
Private Sub TimerTick(sender As Object, e As EventArgs)
splashTimer.Stop()
frmSplash.Close()
End Sub
End Module
Project Settings: