Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. SplashScreen

SplashScreen

Scheduled Pinned Locked Moved Visual Basic
question
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WestSideRailways
    wrote on last edited by
    #1

    Action required :- Splashscreen to stay untill Progressbar has finished

    Public NotInheritable Class SplashScreen1

    Private Sub SplashScreen1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        Form1.Visible = False
        Timer1.Enabled = True
    
    
    End Sub
    
    Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
    
    
        If ProgressBar1.Value <> ProgressBar1.Maximum Then
            ProgressBar1.Value = (ProgressBar1.Value + 1)
            Label1.Text = "Loading " & ProgressBar1.Value & "% Complete"
        End If
    
        If ProgressBar1.Value = 1 Then
            Timer1.Interval = 800
        End If
    
        If ProgressBar1.Value = 2 Then
            Timer1.Interval = 75
        End If
    
        If ProgressBar1.Value = 12 Then
            Timer1.Interval = 600
        End If
    
        If ProgressBar1.Value = 14 Then
            Timer1.Interval = 1500
        End If
    
        If ProgressBar1.Value = 30 Then
            Timer1.Interval = 500
        End If
    
        If ProgressBar1.Value = 50 Then
            Timer1.Interval = 250
        End If
    
        If ProgressBar1.Value = 75 Then
            Timer1.Interval = 100
        End If
    
        If ProgressBar1.Value = 96 Then
            Timer1.Interval = 2000
        End If
    
        If ProgressBar1.Value = 100 Then
            Form1.Visible = True
            Me.Visible = False
        End If
    
    End Sub
    

    End Class

    Can anyone tell me why it's not staying?:confused:

    D C T 3 Replies Last reply
    0
    • W WestSideRailways

      Action required :- Splashscreen to stay untill Progressbar has finished

      Public NotInheritable Class SplashScreen1

      Private Sub SplashScreen1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
          Form1.Visible = False
          Timer1.Enabled = True
      
      
      End Sub
      
      Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      
      
      
          If ProgressBar1.Value <> ProgressBar1.Maximum Then
              ProgressBar1.Value = (ProgressBar1.Value + 1)
              Label1.Text = "Loading " & ProgressBar1.Value & "% Complete"
          End If
      
          If ProgressBar1.Value = 1 Then
              Timer1.Interval = 800
          End If
      
          If ProgressBar1.Value = 2 Then
              Timer1.Interval = 75
          End If
      
          If ProgressBar1.Value = 12 Then
              Timer1.Interval = 600
          End If
      
          If ProgressBar1.Value = 14 Then
              Timer1.Interval = 1500
          End If
      
          If ProgressBar1.Value = 30 Then
              Timer1.Interval = 500
          End If
      
          If ProgressBar1.Value = 50 Then
              Timer1.Interval = 250
          End If
      
          If ProgressBar1.Value = 75 Then
              Timer1.Interval = 100
          End If
      
          If ProgressBar1.Value = 96 Then
              Timer1.Interval = 2000
          End If
      
          If ProgressBar1.Value = 100 Then
              Form1.Visible = True
              Me.Visible = False
          End If
      
      End Sub
      

      End Class

      Can anyone tell me why it's not staying?:confused:

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It's impossible to say why it's not staying up because you haven't shown the code that creates and shows this SplashScreen form. You don't say what your project's Startup Form is either.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      W 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It's impossible to say why it's not staying up because you haven't shown the code that creates and shows this SplashScreen form. You don't say what your project's Startup Form is either.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        W Offline
        W Offline
        WestSideRailways
        wrote on last edited by
        #3

        Dave Kreskowiak wrote:

        It's impossible to say why it's not staying up because you haven't shown the code that creates and shows this SplashScreen form. You don't say what your project's Startup Form is either.

        Startup form is Form1, and you allready have seen the create /show code. The forms for this project are :- SplashScreen Form1 Form2

        D 1 Reply Last reply
        0
        • W WestSideRailways

          Action required :- Splashscreen to stay untill Progressbar has finished

          Public NotInheritable Class SplashScreen1

          Private Sub SplashScreen1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          
              Form1.Visible = False
              Timer1.Enabled = True
          
          
          End Sub
          
          Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
          
          
          
              If ProgressBar1.Value <> ProgressBar1.Maximum Then
                  ProgressBar1.Value = (ProgressBar1.Value + 1)
                  Label1.Text = "Loading " & ProgressBar1.Value & "% Complete"
              End If
          
              If ProgressBar1.Value = 1 Then
                  Timer1.Interval = 800
              End If
          
              If ProgressBar1.Value = 2 Then
                  Timer1.Interval = 75
              End If
          
              If ProgressBar1.Value = 12 Then
                  Timer1.Interval = 600
              End If
          
              If ProgressBar1.Value = 14 Then
                  Timer1.Interval = 1500
              End If
          
              If ProgressBar1.Value = 30 Then
                  Timer1.Interval = 500
              End If
          
              If ProgressBar1.Value = 50 Then
                  Timer1.Interval = 250
              End If
          
              If ProgressBar1.Value = 75 Then
                  Timer1.Interval = 100
              End If
          
              If ProgressBar1.Value = 96 Then
                  Timer1.Interval = 2000
              End If
          
              If ProgressBar1.Value = 100 Then
                  Form1.Visible = True
                  Me.Visible = False
              End If
          
          End Sub
          

          End Class

          Can anyone tell me why it's not staying?:confused:

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          No, we can't. What is Form1 ? How is it set in this class ? How is the SplashSCreen instance created ? This is probably the problem, it's probably not a member variable, and is falling out of scope. The code we need to see, has not been posted. A progress bar that sets itself based solely on a timer is kind of useless.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          W 1 Reply Last reply
          0
          • W WestSideRailways

            Dave Kreskowiak wrote:

            It's impossible to say why it's not staying up because you haven't shown the code that creates and shows this SplashScreen form. You don't say what your project's Startup Form is either.

            Startup form is Form1, and you allready have seen the create /show code. The forms for this project are :- SplashScreen Form1 Form2

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            WestSideRailways wrote:

            you allready have seen the create /show code.

            No, we haven't. All we've seen is the code inside the SplashScreen, not the code that created an instance of it and .Showed it.

            Dave Kreskowiak Microsoft MVP - Visual Basic

            W 1 Reply Last reply
            0
            • C Christian Graus

              No, we can't. What is Form1 ? How is it set in this class ? How is the SplashSCreen instance created ? This is probably the problem, it's probably not a member variable, and is falling out of scope. The code we need to see, has not been posted. A progress bar that sets itself based solely on a timer is kind of useless.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              W Offline
              W Offline
              WestSideRailways
              wrote on last edited by
              #6

              Christian Graus wrote:

              A progress bar that sets itself based solely on a timer is kind of useless.

              Well all it is there for is JUST FOR SHOW:-D

              C 1 Reply Last reply
              0
              • D Dave Kreskowiak

                WestSideRailways wrote:

                you allready have seen the create /show code.

                No, we haven't. All we've seen is the code inside the SplashScreen, not the code that created an instance of it and .Showed it.

                Dave Kreskowiak Microsoft MVP - Visual Basic

                W Offline
                W Offline
                WestSideRailways
                wrote on last edited by
                #7

                Dave Kreskowiak wrote:

                No, we haven't. All we've seen is the code inside the SplashScreen, not the code that created an instance of it and .Showed it.

                Well according to the tutorial on Dream-in-code i don't need to create a instance of it. It works well as is, BUT does not stay on screen long enoght. So you are saying that i need to do something like the following :- dim frmsplash as splashscreen frmsplash.show and this code would be in the handles me.load for form1 ?

                D 1 Reply Last reply
                0
                • W WestSideRailways

                  Action required :- Splashscreen to stay untill Progressbar has finished

                  Public NotInheritable Class SplashScreen1

                  Private Sub SplashScreen1\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                  
                      Form1.Visible = False
                      Timer1.Enabled = True
                  
                  
                  End Sub
                  
                  Private Sub Timer1\_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
                  
                  
                  
                      If ProgressBar1.Value <> ProgressBar1.Maximum Then
                          ProgressBar1.Value = (ProgressBar1.Value + 1)
                          Label1.Text = "Loading " & ProgressBar1.Value & "% Complete"
                      End If
                  
                      If ProgressBar1.Value = 1 Then
                          Timer1.Interval = 800
                      End If
                  
                      If ProgressBar1.Value = 2 Then
                          Timer1.Interval = 75
                      End If
                  
                      If ProgressBar1.Value = 12 Then
                          Timer1.Interval = 600
                      End If
                  
                      If ProgressBar1.Value = 14 Then
                          Timer1.Interval = 1500
                      End If
                  
                      If ProgressBar1.Value = 30 Then
                          Timer1.Interval = 500
                      End If
                  
                      If ProgressBar1.Value = 50 Then
                          Timer1.Interval = 250
                      End If
                  
                      If ProgressBar1.Value = 75 Then
                          Timer1.Interval = 100
                      End If
                  
                      If ProgressBar1.Value = 96 Then
                          Timer1.Interval = 2000
                      End If
                  
                      If ProgressBar1.Value = 100 Then
                          Form1.Visible = True
                          Me.Visible = False
                      End If
                  
                  End Sub
                  

                  End Class

                  Can anyone tell me why it's not staying?:confused:

                  T Offline
                  T Offline
                  TwoFaced
                  wrote on last edited by
                  #8

                  By my calculations your splash screen should stay up for approximatly 56 seconds. That can't possibly be what you intended. Anyway based on your code and description I would say you added a form to your project and selected 'splash screen'. This doesn't mean your application will start with a splash screen. In order for your application to start with the splash screen you need to set that form as your splash screen. To do that you'll need to go to the project properties and under the Application tab you should see 'Splash Screen' with a dropdown to select the desired form. You may have already done that but I couldn't tell if your form was displaying at all. However if you've gotten that far your form will still dissapear once form1 is loaded and the minimum display time has been met, whichever comes second. Since I get the impression your splash screen is simply ornamental I would just pick a time you want it to display. You can set the minimum time in the splash screens 'New' constructor. Use a timer to update the progess bar. The value will be the percentage of time elapsed * 100. So if you want to display for 3 seconds and the elapsed time is 2 secnods the value would be 66. Here's an example of what I mean.

                  Public NotInheritable Class SplashScreen1
                  'Minimum time in seconds to show this splash screen
                  Private Const DisplayTime As Integer = 5

                  WithEvents tmr As New Timer
                  Dim sw As New Stopwatch         'Stopwatch to track time since shown
                  
                  Public Sub New()
                      ' This call is required by the Windows Form Designer.
                      InitializeComponent()
                  
                      'Set minimum time to display
                      My.Application.MinimumSplashScreenDisplayTime = DisplayTime \* 1000
                      'Update progress every 10/1000 sec
                      tmr.Interval = 10
                  End Sub
                  
                  Private Sub tmr\_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
                      'Calculate value for progess bar
                      Dim elapsed As Integer = (sw.ElapsedMilliseconds / (DisplayTime \* 1000)) \* 100
                      If elapsed > 100 Then elapsed = 100
                      ProgressBar1.Value = elapsed
                  End Sub
                  
                  Private Sub SplashScreen1\_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
                      sw.Start()      'Begin stopwatch
                      tmr.Start()     'Start timer
                  End Sub
                  

                  End Class

                  W 1 Reply Last reply
                  0
                  • T TwoFaced

                    By my calculations your splash screen should stay up for approximatly 56 seconds. That can't possibly be what you intended. Anyway based on your code and description I would say you added a form to your project and selected 'splash screen'. This doesn't mean your application will start with a splash screen. In order for your application to start with the splash screen you need to set that form as your splash screen. To do that you'll need to go to the project properties and under the Application tab you should see 'Splash Screen' with a dropdown to select the desired form. You may have already done that but I couldn't tell if your form was displaying at all. However if you've gotten that far your form will still dissapear once form1 is loaded and the minimum display time has been met, whichever comes second. Since I get the impression your splash screen is simply ornamental I would just pick a time you want it to display. You can set the minimum time in the splash screens 'New' constructor. Use a timer to update the progess bar. The value will be the percentage of time elapsed * 100. So if you want to display for 3 seconds and the elapsed time is 2 secnods the value would be 66. Here's an example of what I mean.

                    Public NotInheritable Class SplashScreen1
                    'Minimum time in seconds to show this splash screen
                    Private Const DisplayTime As Integer = 5

                    WithEvents tmr As New Timer
                    Dim sw As New Stopwatch         'Stopwatch to track time since shown
                    
                    Public Sub New()
                        ' This call is required by the Windows Form Designer.
                        InitializeComponent()
                    
                        'Set minimum time to display
                        My.Application.MinimumSplashScreenDisplayTime = DisplayTime \* 1000
                        'Update progress every 10/1000 sec
                        tmr.Interval = 10
                    End Sub
                    
                    Private Sub tmr\_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
                        'Calculate value for progess bar
                        Dim elapsed As Integer = (sw.ElapsedMilliseconds / (DisplayTime \* 1000)) \* 100
                        If elapsed > 100 Then elapsed = 100
                        ProgressBar1.Value = elapsed
                    End Sub
                    
                    Private Sub SplashScreen1\_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
                        sw.Start()      'Begin stopwatch
                        tmr.Start()     'Start timer
                    End Sub
                    

                    End Class

                    W Offline
                    W Offline
                    WestSideRailways
                    wrote on last edited by
                    #9

                    THANKS that works perfectly:-D And i can adjust the time to anything i like.;)

                    1 Reply Last reply
                    0
                    • W WestSideRailways

                      Dave Kreskowiak wrote:

                      No, we haven't. All we've seen is the code inside the SplashScreen, not the code that created an instance of it and .Showed it.

                      Well according to the tutorial on Dream-in-code i don't need to create a instance of it. It works well as is, BUT does not stay on screen long enoght. So you are saying that i need to do something like the following :- dim frmsplash as splashscreen frmsplash.show and this code would be in the handles me.load for form1 ?

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      Something like that... That's the code you're not showing us, or what the code is around that little section.

                      Dave Kreskowiak Microsoft MVP - Visual Basic

                      1 Reply Last reply
                      0
                      • W WestSideRailways

                        Christian Graus wrote:

                        A progress bar that sets itself based solely on a timer is kind of useless.

                        Well all it is there for is JUST FOR SHOW:-D

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        Sure, but your splash screen has to be a member, that's almost certainly why it didn't work before, and then you can call a method to move the progress bar as the program loads. Or, don't have the progress bar, if it doesn't mean anything.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups