SplashScreen
-
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:
-
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:
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
-
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
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
-
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:
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 )
-
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
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
.Show
ed it.Dave Kreskowiak Microsoft MVP - Visual Basic
-
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 )
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
-
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
.Show
ed it.Dave Kreskowiak Microsoft MVP - Visual Basic
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 ?
-
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:
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 = 5WithEvents 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
-
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 = 5WithEvents 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
THANKS that works perfectly:-D And i can adjust the time to anything i like.;)
-
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 ?
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
-
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
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 )