8 Replies - 32207 Views - Last Post: 23 February 2008 - 09:25 PM Rate Topic: -----

#1 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

splash screen in VB2008

Posted 20 February 2008 - 03:32 AM

I am trying to set up a splash screen in VB2008 express and all is working except when i use the progress bar it will go only up to about 18-19% and then open my application. i want it to load on the progress bar all the way 1st then open the program. it seems like the timer is ending before it executes all the IF THEN statements. any ideas?

Public NotInheritable Class SplashScreen1



	Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		'Set up the dialog text at runtime according to the application's assembly information.  
		Timer1.Enabled = True

	'TODO: Customize the application's assembly information in the "Application" pane of the project 
	'  properties dialog (under the "Project" menu).

	'Application title
		If My.Application.Info.Title <> "" Then
			Label1.Text = My.Application.Info.Title
		Else
	'If the application title is missing, use the application name, without the extension
			Label1.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
		End If

	'Format the version information using the text set into the Version control at design time as the
	'  formatting string.  This allows for effective localization if desired.
	'  Build and revision information could be included by using the following code and changing the 
	'  Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar.  See
	'  String.Format() in Help for more information.
	'
	'	Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)

		Label2.Text = (System.String.Format(Label2.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor))

	'Copyright info
		Label3.Text = My.Application.Info.Copyright
	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)
			Label4.Text = "Loading " & ProgressBar1.Value & "% Complete"
		End If

		If ProgressBar1.Value = 100 Then
			FrmMain.Visible = True
			Me.Visible = False

			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 = 4000
			End If

			If ProgressBar1.Value = 15 Then
				Timer1.Interval = 1
			End If

			If ProgressBar1.Value = 17 Then
				Timer1.Interval = 800
			End If

			If ProgressBar1.Value = 21 Then
				Timer1.Interval = 75
			End If

			If ProgressBar1.Value = 23 Then
				Timer1.Interval = 600
			End If

			If ProgressBar1.Value = 25 Then
				Timer1.Interval = 4000
			End If

			If ProgressBar1.Value = 28 Then
				Timer1.Interval = 1
			End If

			If ProgressBar1.Value = 32 Then
				Timer1.Interval = 800
			End If

			If ProgressBar1.Value = 35 Then
				Timer1.Interval = 75
			End If

			If ProgressBar1.Value = 38 Then
				Timer1.Interval = 600
			End If

			If ProgressBar1.Value = 42 Then
				Timer1.Interval = 4000
			End If

			If ProgressBar1.Value = 46 Then
				Timer1.Interval = 1
			End If

			If ProgressBar1.Value = 50 Then
				Timer1.Interval = 800
			End If

			If ProgressBar1.Value = 54 Then
				Timer1.Interval = 75
			End If

			If ProgressBar1.Value = 57 Then
				Timer1.Interval = 600
			End If

			If ProgressBar1.Value = 60 Then
				Timer1.Interval = 4000
			End If

			If ProgressBar1.Value = 66 Then
				Timer1.Interval = 1
			End If

			If ProgressBar1.Value = 69 Then
				Timer1.Interval = 800
			End If

			If ProgressBar1.Value = 73 Then
				Timer1.Interval = 75
			End If

			If ProgressBar1.Value = 77 Then
				Timer1.Interval = 600
			End If

			If ProgressBar1.Value = 79 Then
				Timer1.Interval = 4000
			End If

			If ProgressBar1.Value = 84 Then
				Timer1.Interval = 1
			End If

			If ProgressBar1.Value = 89 Then
				Timer1.Interval = 800
			End If

			If ProgressBar1.Value = 93 Then
				Timer1.Interval = 75
			End If

			If ProgressBar1.Value = 95 Then
				Timer1.Interval = 600
			End If

			If ProgressBar1.Value = 99 Then
				Timer1.Interval = 4000
			End If

		End If

	End Sub

End Class



Is This A Good Question/Topic? 0
  • +

Replies To: splash screen in VB2008

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: splash screen in VB2008

Posted 20 February 2008 - 05:54 AM

I'm not really sure what the purpose of all the If..Else End If statements are for, using the ProgressBar is far simpler than that. All you really need for a ProgressBar is something like:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		ProgressBar1.Minimum = 0
		ProgressBar1.Maximum = 100
		ProgressBar1.Value = 0
		'Set the interval of the timer
		Timer1.Interval = 600 'remember this value is in milliseconds
End Sub




Then in your timer's tick event:


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)
			Label4.Text = "Loading " & ProgressBar1.Value & "% Complete"
	   Else
			FrmMain.Visible = True
			Me.Visible = False
	   End If
End Sub




Like I said, I'm not really sure why you're using so many If statements?
Was This Post Helpful? 1

#3 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

Re: splash screen in VB2008

Posted 20 February 2008 - 10:40 AM

i used so many IF statements to change the speed of the progress bar once it hit that number. As per the tutorial on this site. I even took them all out and debugged it to make sure it wasn't those statements and it did the same thing. Thanks
Was This Post Helpful? 0
  • +
  • -

#4 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

Re: splash screen in VB2008

Posted 20 February 2008 - 11:10 PM

I took your advice and deleted all of that garbage to simplify it and i still get the same thing. i think the application is executing regardless of the timer. the timer is slowing the execution of the program and is ignoring it for that reason. do you think this may be the case?
Was This Post Helpful? 0
  • +
  • -

#5 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

Re: splash screen in VB2008

Posted 21 February 2008 - 02:05 AM

any ideas anyone?
Was This Post Helpful? 0
  • +
  • -

#6 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: splash screen in VB2008

Posted 22 February 2008 - 02:46 AM

Post your most recent code.
Was This Post Helpful? 0
  • +
  • -

#7 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

Re: splash screen in VB2008

Posted 22 February 2008 - 02:53 AM

Public NotInheritable Class SplashScreen1

	Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  

		Timer1.Enabled = True

		ProgressBar1.Minimum = 0
		ProgressBar1.Maximum = 100
		ProgressBar1.Value = 1
		Timer1.Interval = 600

		If My.Application.Info.Title <> "" Then
			Label1.Text = My.Application.Info.Title
		Else
			Label1.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
		End If

		Label2.Text = (System.String.Format(Label2.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor))

		
		Label3.Text = My.Application.Info.Copyright
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

		If ProgressBar1.Value + 1 < ProgressBar1.Maximum Then
			ProgressBar1.Value = (ProgressBar1.Value + 1)
			Label4.Text = "Loading " & ProgressBar1.Value & "% Complete"
		Else
			Form1.Visible = True
			Me.Visible = False
		End If
	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: splash screen in VB2008

Posted 22 February 2008 - 04:59 PM

I am guessing that you have in your Project Properties set the Splash Screen property to the name of your splash screen, is that correct?

I think when you use this property it has its' own internal timer.

To bypass this problem, set the Project Properties for Splash Screen to "none" and instead inside the load event of your Form1 put the following line of code as the first line in that event.
   Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		SplashScreen1.ShowDialog()

	End Sub


This will allow the progress bar to reach its maximum value before showing the Form1.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

#9 GetThatFooty  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 02-February 08

Re: splash screen in VB2008

Posted 23 February 2008 - 09:25 PM

Beautiful. Thank You.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1