7 Replies - 18285 Views - Last Post: 05 August 2008 - 11:11 AM Rate Topic: -----

#1 kndollaga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-June 08

Creating Splash screen and opening another form

Post icon  Posted 24 June 2008 - 03:43 AM

Hello! I'm new in VB.Net and I am currently trying to make a Splash Screen and I use Timer to unload/hide the splash screen to open another form and it goes like this:

Timer Property:
Enabled = True
Interval = 8000

Code:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
			Me.Hide()
			Dim frmSplash As New Form2
			frmSplash.Show()
End Sub



The problem is this: the splash screen closes and the Form2 opens but after a second or more another form2 open (same Form2) even though there's no code that will open the Form2 2 times..

What should I do?

Thanks.

-Kelsey

Is This A Good Question/Topic? 0
  • +

Replies To: Creating Splash screen and opening another form

#2 narmer93  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 317
  • Joined: 13-March 08

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 04:21 AM

i think this is the code u need if the splash screen is the start form and u want it to open a form
note:open project,projectname properties and there will be a choise for the start form and how to close
Public Class Form1
    Dim x As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
        Timer1.Interval = 1000
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        x += 1
        If x = 8 Then 'if u want the action to be made after 8seconds'
            SplashScreen1.Show()
            Me.Hide() 'or me.Close if u set the close way in properties area to close when the last form closes' 
        End If
    End Sub
End Class


sorry i made a mistake in the code 'the code in the form1 area should be in the splash screen area if the splashscreen is the first form
i hope this helps
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 09:01 AM

Your timer is still running on your splash screen. As a result, it will continue to open a new form every time the Tick event fires.

You need to stop the timer, once you open your main form.
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
			Me.Hide()
			Dim frmSplash As New Form2
			frmSplash.Show()
			Timer1.Stop()
End Sub


Was This Post Helpful? 0
  • +
  • -

#4 gram999  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 89
  • Joined: 21-January 08

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 11:42 AM

Can't you just use the following property:

My.Application.MinimumSplashScreenDisplayTime

While you cannot set this in the Startup event couldn't you set it in the New constructor for the SplashScreen before InitializeComponent().

Just an idea.
Was This Post Helpful? 0
  • +
  • -

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 01:14 PM

gram999, that property only exists if you add a Splash Screen Form to your project. I believe in this case, the OP created a standard form and is utilizing it as a splash screen.
Was This Post Helpful? 0
  • +
  • -

#6 Damage  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 27
  • View blog
  • Posts: 1,079
  • Joined: 05-June 08

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 01:30 PM

well he did say he's new tp vb.net, maybe he doesn't realise that you can just add a splash form instead of adding a regular windows form
Was This Post Helpful? 0
  • +
  • -

#7 WayneSpangler  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 106
  • Joined: 22-March 08

Re: Creating Splash screen and opening another form

Posted 24 June 2008 - 06:29 PM

Double click the project in solution explorer.
In the Application tab at the bottom click on "View Application Events" button.
Add this code:
	Partial Friend Class MyApplication
		Protected Overrides Function OnInitialize( _
	ByVal commandLineArgs As  _
	System.Collections.ObjectModel.ReadOnlyCollection(Of String) _
) As Boolean
			' Set the display time to 5000 milliseconds (5 seconds). 
			Me.MinimumSplashScreenDisplayTime = 5000
			Return MyBase.OnInitialize(commandLineArgs)
		End Function
	End Class


Was This Post Helpful? 0
  • +
  • -

#8 paulauskas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-August 08

Re: Creating Splash screen and opening another form

Posted 05 August 2008 - 11:11 AM

View Postkndollaga, on 24 Jun, 2008 - 03:43 AM, said:

Hello! I'm new in VB.Net and I am currently trying to make a Splash Screen and I use Timer to unload/hide the splash screen to open another form and it goes like this:

Timer Property:
Enabled = True
Interval = 8000

Code:
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
			Me.Hide()
			Dim frmSplash As New Form2
			frmSplash.Show()
End Sub



The problem is this: the splash screen closes and the Form2 opens but after a second or more another form2 open (same Form2) even though there's no code that will open the Form2 2 times..

What should I do?

Thanks.

-Kelsey

I would accomplish it like this:
add this to Form1_Load
Me.Hide()
frmSplash.Show()
Timer1.Enabled = True

The set the Timer to Disabled with an Interval of however many milliseconds you want, probably around 2000
And then within the Timer add the following:
Form1.Show()
Me.Hide
Timer1.Enabled = False

If you do not disable the time it will keep instantiating a new Form2 every interval. I hope this helps.

Matt
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1