JayBeeOH

Splash Screen Demo

Dec 7th, 2016
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.28 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2016. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Splash Screen Demo
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   07 DEC 2016
  16. '
  17. ' Description:    Demonstrate how to use Progress Bar in a "artificially" controlled
  18. '                 Splash Screen display.
  19. '
  20. '                 Documentation is at:
  21. '                   App's screen image is at: http://imgur.com/W1MJO4t
  22. '                   App's Visual Basic .NET code is at: http://pastebin.com/k6q5yaLt  
  23. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  24. '
  25. '                 NOTE: For this project to work correctly, on the Application Tab of the
  26. '                       project, set the following:
  27. '                            Startup form : SplashSceeenForm
  28. '                            Shutdown mode: When last form closes
  29. '                            Splash screen: (None)
  30. '
  31. '                 For true Splash Screen processing, see:
  32. '                      "My.Application.MinimumSplashScreenDisplayTime Property"
  33. '                      https://msdn.microsoft.com/en-us/library/ms234874(v=vs.90).aspx
  34. '
  35. '-------------------------------------------------------------------------------------------
  36.  
  37. Public Class SplashScreenForm
  38.  
  39.     Private WithEvents MyTimer As New Timer
  40.     Private progressBarIncrement As Integer
  41.     Const SPLASH_SCREEN_DISPLAY_TIME As Integer = 5    ' Number of seconds to display screen
  42.  
  43.     Private Sub SplashScreenForm_Load(sender As Object, e As EventArgs) _
  44.         Handles MyBase.Load
  45.  
  46.         With MyProgressBar
  47.             .Maximum = 1000
  48.             .Style = ProgressBarStyle.Continuous
  49.         End With
  50.  
  51.         ' The incremental value has been set to 5% of Splash Screen wait time.
  52.         progressBarIncrement = Convert.ToInt32((MyProgressBar.Maximum / (SPLASH_SCREEN_DISPLAY_TIME / 20)) * 0.01)
  53.  
  54.         StatusLabel.Text = "Loading ..."
  55.  
  56.         MyTimer.Interval = (1000 * SPLASH_SCREEN_DISPLAY_TIME) \ 20
  57.         MyTimer.Start()
  58.  
  59.     End Sub
  60.  
  61.     Private Sub MyTimer_Tick(sender As Object, e As EventArgs) _
  62.         Handles MyTimer.Tick
  63.  
  64.         Static loadingProgress As Integer = 0
  65.         loadingProgress += progressBarIncrement
  66.  
  67.         If loadingProgress >= MyProgressBar.Maximum Then
  68.             loadingProgress = MyProgressBar.Maximum
  69.             MyTimer.Stop()
  70.             StatusLabel.Text = "Ready"
  71.  
  72.             ' Transfer control to MainForm
  73.             Dim mainForm As New MainForm
  74.             mainForm.Show()
  75.             Me.Close()
  76.         End If
  77.  
  78.         MyProgressBar.Value = loadingProgress
  79.  
  80.     End Sub
  81. End Class
Advertisement
Add Comment
Please, Sign In to add comment