JayBeeOH

Better Splash Screen Demo

Dec 10th, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.13 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.     Const SPLASH_SCREEN_DISPLAY_TIME As Integer = 5     ' Number of seconds to display screen
  41.     Const FRAMES_PER_SECOND As Integer = 30             ' Frames per second
  42.  
  43.     Private Sub SplashScreenForm_Load(sender As Object, e As EventArgs) _
  44.         Handles MyBase.Load
  45.  
  46.         With MyProgressBar
  47.             .Maximum = SPLASH_SCREEN_DISPLAY_TIME * FRAMES_PER_SECOND
  48.             .Step = 1
  49.             .Value = 1
  50.             .Style = ProgressBarStyle.Continuous
  51.         End With
  52.  
  53.         StatusLabel.Text = "Loading ..."
  54.  
  55.         MyTimer.Interval = 1000 \ FRAMES_PER_SECOND
  56.         MyTimer.Start()
  57.  
  58.     End Sub
  59.  
  60.     Private Sub MyTimer_Tick(sender As Object, e As EventArgs) _
  61.         Handles MyTimer.Tick
  62.  
  63.         MyProgressBar.PerformStep()
  64.         StatusLabel.Text = String.Format("{0:N0} %", (MyProgressBar.Value / MyProgressBar.Maximum * 100))
  65.  
  66.         If MyProgressBar.Value >= MyProgressBar.Maximum Then
  67.  
  68.             MyTimer.Stop()
  69.             StatusLabel.Text = "Ready"
  70.  
  71.             ' Transfer control to MainForm
  72.             Dim frm As New MainForm
  73.             frm.Show()
  74.             Me.Close()
  75.         End If
  76.  
  77.     End Sub
  78. End Class
Advertisement
Add Comment
Please, Sign In to add comment