Results 1 to 3 of 3

Thread: Timer for a splash screen

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    64

    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

  2. #2
    Junior Member Alucard's Avatar
    Join Date
    Apr 2007
    Posts
    27

    Re: Timer for a splash screen

    How about something like this, does this help you?

    VB Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Timer1.Enabled = True
    5.     End Sub
    6.  
    7.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    8.         With ProgressBar1
    9.             .Minimum = 0
    10.             .Maximum = 100
    11.             .Value = .Value + 10
    12.             If .Value = .Maximum Then
    13.                 Timer1.Enabled = False
    14.                 Me.Hide()
    15.                 Form2.Show()
    16.             End If
    17.         End With
    18.     End Sub
    19. End Class

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. Me.progress.PerformStep()
    2.  
    3. If Me.progress.Value >= Me.progress.Maximum Then
    4.     Me.Timer1.Stop()
    5. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width