|
-
Apr 22nd, 2007, 08:23 AM
#1
Thread Starter
Lively Member
Timer for a splash screen
Hi i am using visual studio 05 and have created a splash screen but i want to set it to a timer. I also have a progress bar so i want that to count up to what the timer is.
Here is my splash screen code :
Code:
Public NotInheritable Class splash
Private Sub splash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load, ApplicationTitle.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If progress.Value <> progress.Maximum Then
progress.Value = (progress.Value + 20)
End If
End Sub
End Class
Thanks heaps guys
Cheers
-
Apr 22nd, 2007, 12:28 PM
#2
Junior Member
Re: Timer for a splash screen
How about something like this, does this help you?
VB Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
With ProgressBar1
.Minimum = 0
.Maximum = 100
.Value = .Value + 10
If .Value = .Maximum Then
Timer1.Enabled = False
Me.Hide()
Form2.Show()
End If
End With
End Sub
End Class
-
Apr 22nd, 2007, 07:15 PM
#3
Re: Timer for a splash screen
You don't use a Timer to control a splash screen. There is a specific mechanism provided for ensuring that a splash screen is visible for a specific amount of time. There's no way to control the maximum time and nor should there be. If your main form takes a long time to load then your splash screen should be visible for a long time. You can, however, ensure that your splash screen is visible for a specific minimum time. The default is 2 seconds but you can change that. Look up the MinimumSplashScreeDisplayTime property and it will provide a code example and an explanation.
As for your ProgressBar, what is the point really? Users know that splash screens appear before the main form. If your ProgresBar isn't actually displaying any real progress then what purpose does it serve? If you need to keep the user from thinking that there's a problem then you're displaying your splash screen for too long. Also, if loading the main form takes longer than it does to fill the ProgressBar then you're actually feeding the user false information and that's worse than no information at all.
If you're determined to go ahead with the ProgressBar idea then you should use the in-built functionality. Set the Step property and then call the PerformStep method. You would only set the Value directly if it was changing by a variable amount.
vb Code:
Me.progress.PerformStep()
If Me.progress.Value >= Me.progress.Maximum Then
Me.Timer1.Stop()
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|