Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2016. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Splash Screen Demo
- '
- ' Author: Joseph L. Bolen
- ' Date Created: 07 DEC 2016
- '
- ' Description: Demonstrate how to use Progress Bar in a "artificially" controlled
- ' Splash Screen display.
- '
- ' Documentation is at:
- ' App's screen image is at: http://imgur.com/W1MJO4t
- ' App's Visual Basic .NET code is at: http://pastebin.com/k6q5yaLt
- ' Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
- '
- ' NOTE: For this project to work correctly, on the Application Tab of the
- ' project, set the following:
- ' Startup form : SplashSceeenForm
- ' Shutdown mode: When last form closes
- ' Splash screen: (None)
- '
- ' For true Splash Screen processing, see:
- ' "My.Application.MinimumSplashScreenDisplayTime Property"
- ' https://msdn.microsoft.com/en-us/library/ms234874(v=vs.90).aspx
- '
- '-------------------------------------------------------------------------------------------
- Public Class SplashScreenForm
- Private WithEvents MyTimer As New Timer
- Private progressBarIncrement As Integer
- Const SPLASH_SCREEN_DISPLAY_TIME As Integer = 5 ' Number of seconds to display screen
- Private Sub SplashScreenForm_Load(sender As Object, e As EventArgs) _
- Handles MyBase.Load
- With MyProgressBar
- .Maximum = 1000
- .Style = ProgressBarStyle.Continuous
- End With
- ' The incremental value has been set to 5% of Splash Screen wait time.
- progressBarIncrement = Convert.ToInt32((MyProgressBar.Maximum / (SPLASH_SCREEN_DISPLAY_TIME / 20)) * 0.01)
- StatusLabel.Text = "Loading ..."
- MyTimer.Interval = (1000 * SPLASH_SCREEN_DISPLAY_TIME) \ 20
- MyTimer.Start()
- End Sub
- Private Sub MyTimer_Tick(sender As Object, e As EventArgs) _
- Handles MyTimer.Tick
- Static loadingProgress As Integer = 0
- loadingProgress += progressBarIncrement
- If loadingProgress >= MyProgressBar.Maximum Then
- loadingProgress = MyProgressBar.Maximum
- MyTimer.Stop()
- StatusLabel.Text = "Ready"
- ' Transfer control to MainForm
- Dim mainForm As New MainForm
- mainForm.Show()
- Me.Close()
- End If
- MyProgressBar.Value = loadingProgress
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment