## Startup Forms and Splash screen Problem - Please help me!! ##

  • Thread starter Thread starter BuzzLight
  • Start date Start date
B

BuzzLight

This is my problem :-

- I have set a form frmSplash as the startup form instead of sub Main.
- This means I dont create an instance of it myself at startup.. its automatically created.
- I have a timer on frmSplash set to 3000 ms interval - and here is its tick event :

Private Sub tmrStartup_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrStartup.Tick
Dim frmParent As New frmParent
frmParent.Show()
Me.Close()
End Sub

Now what I thought was that after the first tick at 3sec it would create an instance to frmParent and show that then close itself(frmSplash)... but sadly what happens it that the "me.close" closes the whole app. Ive tried me.close before the "Dim frmParent As New frmParent" but same result.. the application closes and frmParent is closed.

What I want to happen is frmSplash should close and show frmParent.

Thanks for Looking.
 
Can I suggest an alternative approach ...

Rather than have a form as the startup object, create a Sub Main and make
that the start object.

In Sub Main, create and show your splash form, and when it closes call
Application.Run() for your main form.

Better still, if you don't use a timer but let the splash screen return
immediately, you can carry on and perform initialisation whilst the splash
screen is up, and then close it when the longer of initialisation and three
seconds occurs.

HTH

Charles


BuzzLight said:
This is my problem :-

- I have set a form frmSplash as the startup form instead of sub Main.
- This means I dont create an instance of it myself at startup.. its automatically created.
- I have a timer on frmSplash set to 3000 ms interval - and here is its tick event :

Private Sub tmrStartup_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tmrStartup.Tick
Dim frmParent As New frmParent
frmParent.Show()
Me.Close()
End Sub

Now what I thought was that after the first tick at 3sec it would create
an instance to frmParent and show that then close itself(frmSplash)... but
sadly what happens it that the "me.close" closes the whole app. Ive tried
me.close before the "Dim frmParent As New frmParent" but same result.. the
application closes and frmParent is closed.
 
Hi BuzzLight,

Reading the text from Charles I changed my splashform a little bit.
(I was using showdialog)
I hope this helps?

Cor


\\\form1
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim frm As New Form2
frm.Show()
End Sub
///
\\\form2
Private WithEvents timer1 As New Windows.Forms.Timer
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "High I Am Here"
Me.ForeColor = Color.White
timer1.Enabled = True
timer1.Interval = 125
Me.BackColor = Color.CornflowerBlue
Me.Opacity = 1
Me.TopMost = True
Me.Text = "Splash"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
Me.Opacity -= 0.01
If Me.Opacity = 0 Then
timer1.Enabled = False
Me.Close()
End If
End Sub
///
 
Back
Top