14 Replies - 3549 Views - Last Post: 23 January 2010 - 11:08 PM Rate Topic: -----

#1 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Question about progress bar?

Post icon  Posted 23 January 2010 - 08:46 PM

Hello everyone
I wanted to know how I can slow down my progress bar timer.
Right now my code is
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		Timer1.Start()
	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		MsgBox("Press ok to connect to database.", MsgBoxStyle.OkCancel)
		ProgressBar1.Increment(+100)

	End Sub
End Class



I want to slow down how fast the progress bar speeds through it.
And once its finished I want a spraet message to pop up saying finished or connected.
How can i do this

Is This A Good Question/Topic? 0
  • +

Replies To: Question about progress bar?

#2 PsychoCoder  Icon User is offline

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

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

Re: Question about progress bar?

Posted 23 January 2010 - 08:48 PM

Since this is VB.NET code I'm moving this to the VB.NET forum for you :)
Was This Post Helpful? 0
  • +
  • -

#3 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 09:19 PM

So you don't want the progress bar to reflect the progress, you just want an animation? Sure.

Public Sub giveUserIllusionOfProgress()
		Timer1.Enabled = True
		Timer1.Interval = 100 'change this to your liking
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 Then
Timer1.Enabled = False			
MsgBox("Connected to database")
			
		End If
	End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		MsgBox("Press ok to connect to database.", MsgBoxStyle.OkCancel)
	 giveUserIllusionOfProgress()

	End Sub




EDIT: Made crucial change in code.

This post has been edited by LeisureProgrammer: 23 January 2010 - 09:24 PM

Was This Post Helpful? 0
  • +
  • -

#4 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 09:27 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 08:19 PM, said:

So you don't want the progress bar to reflect the progress, you just want an animation? Sure.

Public Sub giveUserIllusionOfProgress()
		Timer1.Enabled = True
		Timer1.Interval = 100 'change this to your liking
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 Then
Timer1.Enabled = False			
MsgBox("Connected to database")
			
		End If
	End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		MsgBox("Press ok to connect to database.", MsgBoxStyle.OkCancel)
	 giveUserIllusionOfProgress()

	End Sub




EDIT: Made crucial change in code.


Ok so i got
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 Then
			MsgBox("Connected to database")
			Timer1.Enabled = False
		End If
	End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		MsgBox("Press ok to connect to database.", MsgBoxStyle.OkCancel)
	 giveUserIllusionOfProgress()

	End Sub



But where do i put
Public Sub giveUserIllusionOfProgress()
		Timer1.Enabled = True
		Timer1.Interval = 100 'change this to your liking
	End Sub


I added the stuff of the other 2 things but idk where to put that
Was This Post Helpful? 0
  • +
  • -

#5 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 09:28 PM

It's another sub, just put it below any "End Sub"

Oh, and be sure to change this to that! :o

This
If ProgressBar1.Value = 100 Then
			MsgBox("Connected to database")
			Timer1.Enabled = False
		End If



To:
If ProgressBar1.Value = 100 Then
  Timer1.Enabled = False
			MsgBox("Connected to database")		  
		End If


This post has been edited by LeisureProgrammer: 23 January 2010 - 09:29 PM

Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

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

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

Re: Question about progress bar?

Posted 23 January 2010 - 09:32 PM

And since you're working with VB.NET change this

MsgBox("Connected to database")



To

MessageBox.Show(Connected to database")


:)
Was This Post Helpful? 0
  • +
  • -

#7 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 09:46 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 08:28 PM, said:

It's another sub, just put it below any "End Sub"

Oh, and be sure to change this to that! :o

This
If ProgressBar1.Value = 100 Then
			MsgBox("Connected to database")
			Timer1.Enabled = False
		End If



To:
If ProgressBar1.Value = 100 Then
  Timer1.Enabled = False
			MsgBox("Connected to database")		  
		End If




Thanks that worked. You are a BEAST!
Now I'm wondering
I have another button
Its called verify
When i press it right now it changed button 2 i think to say verified
Here is the code i have

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 Then
			Timer1.Enabled = False
			MsgBox("Connected to script database!")
		End If

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		MsgBox("Press ok to connect to script database.", MsgBoxStyle.OkCancel)
		giveUserIllusionOfProgress()

	End Sub
	Public Sub giveUserIllusionOfProgress()
		Timer1.Enabled = True
		Timer1.Interval = 50 'change this to your liking
	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
		Button2.Text = "Verified!"
	End Sub

End Class


When i press button3 right now it changes button 2 to say verrified
I want it to redo the progress bar over again then a msg to pop up saying something like verrificatin suscessful
Then also make button 2 change to Verified!

You are awsome for helping me with all this (=
Was This Post Helpful? 0
  • +
  • -

#8 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 10:05 PM

Well TY :D
Looks like you're not enjoying VB.NET :(, if you paid attention - you would have been able(and had as much fun as me) to do the next step yourself. I don't think you're going to learn anything, but :P

Replace the previous timer sub with:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Connected to database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Verified")
			Exit Sub
		End If
	End Sub



Add this between any "End Sub" and the start of a sub
	Dim lol As Boolean = False



And add this:
Public Sub doItAgain()
		Timer1.Enabled = True
		Timer1.Interval = 10 'change this to your liking
		ProgressBar1.Value = 0
	End Sub



And finally, this:
  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
		Button2.Text = "Verified!"
	End Sub



LOL, if you don't understand a part, and want to understand it - feel free to ask.

This post has been edited by LeisureProgrammer: 23 January 2010 - 10:21 PM

Was This Post Helpful? 0
  • +
  • -

#9 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 10:21 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 09:05 PM, said:

Well TY :D
Looks like you're not enjoying VB.NET :(, if you paid attention - you would have been able to do the next step yourself. I don't think you're going to learn anything, but :P

Replace the previous timer sub with:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Connected to database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Verified")
			Exit Sub
		End If
	End Sub



Add this between any "End Sub" and the start of a sub
	Dim lol As Boolean = False



And add this:
Public Sub doItAgain()
		Timer1.Enabled = True
		Timer1.Interval = 10 'change this to your liking
		ProgressBar1.Value = 0
	End Sub



And finally, this:
  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 
		Button2.Text = "Verified!"
	End Sub



LOL, if you don't understand a part, and want to understand it - feel free to ask.


Truse me you are teachin me ALOT
I have saved these pages on book marks
Also to prove what i have learned i found one of your mistakes
At first i did everything you said and it didnt work
So i went back and changed

 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Button2.Text = "Verified!"
	End Sub


to
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		doItAgain()
		Button2.Text = "Verified!"
	End Sub


But another question.
Once i press button 3 it changed button to to say verified and starts loading the bar over again at same time
Is there any way I can make it wait to change button 2 to say verified after the progress bar finishes and
the Verified msg pops up.
Like after i press ok on that message it changes button 2 to verified
Also thanks for your help.
I would donate to you
Just add my msn at roppolocarlo@live.com if you would like
You rock and im learning so much!
Was This Post Helpful? 0
  • +
  • -

#10 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 10:26 PM

Quote

Also thanks for your help.
I would donate to you

LOL, look carefully at the last line of my signature if you really want to thank me on any post - it's free ;)

You can move this:
Button2.Text = "Verified!"
to here:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Connected to database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Verified")
Button2.Text = "Verified!"
			Exit Sub
		End If
	End Sub



LOL Yes, my code is full of mistakes :)

This post has been edited by LeisureProgrammer: 23 January 2010 - 10:27 PM

Was This Post Helpful? 1
  • +
  • -

#11 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 10:41 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 09:26 PM, said:

Quote

Also thanks for your help.
I would donate to you

LOL, look carefully at the last line of my signature if you really want to thank me on any post - it's free ;)

You can move this:
Button2.Text = "Verified!"
to here:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Connected to database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Verified")
Button2.Text = "Verified!"
			Exit Sub
		End If
	End Sub



LOL Yes, my code is full of mistakes :)



Thanks im learning alot.
Now my current code it
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Successfully connected to script database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Database connection Verified!")
			Button2.Text = "Verified!"
			Button3.Text = "Database connection verified!"
			Exit Sub
		End If
	End Sub
	Dim lol As Boolean = False

	Public Sub doItAgain()
		Timer1.Enabled = True
		Timer1.Interval = 10 'change this to your liking
		ProgressBar1.Value = 0
	End Sub


	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		giveUserIllusionOfProgress()

	End Sub
	Public Sub giveUserIllusionOfProgress()
		Timer1.Enabled = True
		Timer1.Interval = 50 'change this to your liking
	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		doItAgain()
		Button2.Text = "Verifying..."
	End Sub


End Class


After both buttons are verified basicly at the end how can i make it to where you cannot click the buttons again.
Make it to where they arnt clickable
Im guessing it would be added here
ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Database connection Verified!")
			Button2.Text = "Verified!"
			Button3.Text = "Database connection verified!"
			Exit Sub
		End If
	End Sub


But idk what the code is.
You are a major help and i will for shure make an A+++ on my project
Was This Post Helpful? 0
  • +
  • -

#12 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 10:47 PM

You can disable a button like this Button2.Enabled = False
But VB doesn't automatically make it *obvious* that it's disabled, so you might want to do something like this Button2.BackColor = Color.Red

And I'm pretty sure you're right about where it should go.

Quote

You are a major help and i will for shure make an A+++ on my project

That makes me feel soo nice :wub:

This post has been edited by LeisureProgrammer: 23 January 2010 - 10:48 PM

Was This Post Helpful? 0
  • +
  • -

#13 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 10:58 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 09:47 PM, said:

You can disable a button like this Button2.Enabled = False
But VB doesn't automatically make it *obvious* that it's disabled, so you might want to do something like this Button2.BackColor = Color.Red

And I'm pretty sure you're right about where it should go.

Quote

You are a major help and i will for shure make an A+++ on my project

That makes me feel soo nice :wub:

That worked but the text is black which makes it hard to read
I tryed adding
Button2.ForeColor = Color.White

But that didnt work.
Whats the code to change the text color to white so it will pop on the red background
Current code.
ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Database connection Verified!")
			Button2.Text = "Verified!"
			Button3.Text = "Database connection verified!"
			Button2.Enabled = False
			Button2.BackColor = Color.Red
			Exit Sub
		End If
	End Sub

Was This Post Helpful? 0
  • +
  • -

#14 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Question about progress bar?

Posted 23 January 2010 - 11:02 PM

Button2.ForeColor = Color.White

That should work to change the font colour, are you sure you added that to the right place?
Was This Post Helpful? 0
  • +
  • -

#15 6010fd12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 11-January 10

Re: Question about progress bar?

Posted 23 January 2010 - 11:08 PM

View PostLeisureProgrammer, on 23 Jan, 2010 - 10:02 PM, said:

Button2.ForeColor = Color.White

That should work to change the font colour, are you sure you added that to the right place?


Yes i added it right here
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		ProgressBar1.Value += 1
		If ProgressBar1.Value = 100 And lol = False Then
			Timer1.Enabled = False
			MsgBox("Successfully connected to script database")
			lol = True
			Exit Sub
		ElseIf ProgressBar1.Value = 100 And lol = True Then
			Timer1.Enabled = False
			MsgBox("Database connection Verified!")
			Button2.Text = "Verified!"
			Button3.Text = "Database connection verified!"
			Button2.Enabled = False
			Button2.ForeColor = Color.White
			Button2.BackColor = Color.Red
			Exit Sub
		End If
	End Sub


It changed the back color to red but the text is still black.
That should be the right place.
But thats the right place.
Also when i press forecolor on the main menue to change it there is no option for white
They are like window and etc options that change color
but when i try one of thos i get a blue line under it.
Any ideas do you need my whole code.
Also ur epic i tryed to thank you but it gives me error and wont let me leve comment or thank

EDIT:
It will change the text color to white if i dont add
Button2.Enabled = False
But the button will still work

This post has been edited by 6010fd12: 23 January 2010 - 11:15 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1