Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim FormToOpen As Type FormToOpen = GetType(Form1) Dim frm As Form = CType(Activator.CreateInstance(FormToOpen), Form) frm.Show() End Sub End Class
countdown timer
Page 1 of 19 Replies - 4154 Views - Last Post: 05 January 2009 - 07:58 AM
#1
countdown timer
Posted 04 January 2009 - 12:12 PM
I have created a splashscreen which i want to close after 3 seconds and open form1. The problem I am having is that it keeps opening a new form1 every 3 seconds. help please
Replies To: countdown timer
#2
Re: countdown timer
Posted 04 January 2009 - 12:19 PM
Close the main form (splash screen) after the form was shown:
Me.Close()
This post has been edited by Core: 04 January 2009 - 12:20 PM
#3
Re: countdown timer
Posted 04 January 2009 - 12:21 PM
I use KISS 
Make sure your start up form is set to your main form, ie. not the splash screen and put this code in your form load method:
Make sure your start up form is set to your main form, ie. not the splash screen and put this code in your form load method:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'show splash screen Me.Hide() Dim frmSplash As New Splash_screen frmSplash.Show() frmSplash.Update() '5 second delay to show splash screen System.Threading.Thread.Sleep(5000) frmSplash.Close() Me.Visible = True End Sub
steveshergill, on 4 Jan, 2009 - 11:12 AM, said:
I have created a splashscreen which i want to close after 3 seconds and open form1. The problem I am having is that it keeps opening a new form1 every 3 seconds. help please
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim FormToOpen As Type FormToOpen = GetType(Form1) Dim frm As Form = CType(Activator.CreateInstance(FormToOpen), Form) frm.Show() End Sub End Class
#4
Re: countdown timer
Posted 04 January 2009 - 12:38 PM
kryton46, on 4 Jan, 2009 - 11:21 AM, said:
I use KISS 
Make sure your start up form is set to your main form, ie. not the splash screen and put this code in your form load method:
Make sure your start up form is set to your main form, ie. not the splash screen and put this code in your form load method:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'show splash screen Me.Hide() Dim frmSplash As New Splash_screen frmSplash.Show() frmSplash.Update() '5 second delay to show splash screen System.Threading.Thread.Sleep(5000) frmSplash.Close() Me.Visible = True End Sub
steveshergill, on 4 Jan, 2009 - 11:12 AM, said:
I have created a splashscreen which i want to close after 3 seconds and open form1. The problem I am having is that it keeps opening a new form1 every 3 seconds. help please
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim FormToOpen As Type FormToOpen = GetType(Form1) Dim frm As Form = CType(Activator.CreateInstance(FormToOpen), Form) frm.Show() End Sub End Class
what do you mean by mainform? Do you mean form1?
#5
Re: countdown timer
Posted 04 January 2009 - 12:41 PM
For your splashscreen, just use the following code in the timer:
Change Form2 to the name of your main working form.
Dim form2 As New Form2 form2.Show() Me.Close()
Change Form2 to the name of your main working form.
This post has been edited by Core: 04 January 2009 - 12:42 PM
#6
Re: countdown timer
Posted 04 January 2009 - 12:54 PM
You kissed my KISS 
This has got to be the cleanest and neatest solution for splash screens, txs Core.
This has got to be the cleanest and neatest solution for splash screens, txs Core.
Core, on 4 Jan, 2009 - 11:41 AM, said:
For your splashscreen, just use the following code in the timer:
Change Form2 to the name of your main working form.
Dim form2 As New Form2 form2.Show() Me.Close()
Change Form2 to the name of your main working form.
#7
Re: countdown timer
Posted 04 January 2009 - 02:32 PM
this doesnt seem to work. I have set the properties to enabled true and interval 5000. When i run it, it just closes everything down. please help
#8
Re: countdown timer
Posted 04 January 2009 - 02:38 PM
Most likely it is because the splash screen is the first form in your application. So, if your project settings are set to default, the application will shutdown when first form closes. So, as you close the first form, the applications closes too. To change this, right click on the project name in Solution Explorer window and select Properties. Change the Shutdown Mode property to When last form closes.
#9
Re: countdown timer
Posted 04 January 2009 - 04:40 PM
thanks for every1s help. really appreciate it. the timer problem has no been resolved
#10
Re: countdown timer
Posted 05 January 2009 - 07:58 AM
WOW! .Net has a mechanism already in place for controlling the amount of time a splash screen is shown...
in the project settings, set the Splash Screen to your splash screen
in ApplicationEvents.vb
in the project settings, set the Splash Screen to your splash screen
in ApplicationEvents.vb
Protected Overrides Function OnInitialize _ (ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) _ As Boolean ' Set the display time to 3000 milliseconds (3 seconds). Me.MinimumSplashScreenDisplayTime = 3000 Return MyBase.OnInitialize(commandLineArgs) End Function
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|