I'm coding a splash screen in VB.Net that displays for 3 seconds then shows a login screen. But the splash shows up even when login shows and I have told the splash to hide. Here is my code:
Public Class frmSplash
Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Show()
System.Threading.Thread.Sleep(3000)
Me.Hide()
frmLogin.Show()
End Sub
End Class
Calling Thread.Sleep
in the UI thread will freeze your program.
Also, the Load event fires before the form is shown, so you're calling Hide
before the form is shown in the first place.
You need to add a Timer component to the form, set its Interval
to 3000
, and call Close
in its Tick
event. Then, call the timer's Start
method in the forms Shown
event.