Show message while progressbar is processing
So I want to make a Text while ProgressBar is processing. A text will show below the progressbar like. "Please wait...." then a second text if it hits the middle of the bar it will say "Verifying..." and the last text if it hits the last bar or the end will be "Complete!" something like this..
This are my codes
Code:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1)
If ProgressBar1.Value = ProgressBar1.Maximum Then
Button2.Enabled = True
End If
Label2.Text = ProgressBar1.Value & (" %")
End Sub
Code:
Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles ProgressBar1.Click
End Sub
Thanks!
Re: Show message while progressbar is processing
Firstly, ProgressBars don't process anything. They just sit there showing a fraction in a fancy UI. You do the processing in code and then you set the fraction being displayed in the ProgressBar to indicate where that code is up to.
As for the question, I'm not sure what the problem is. If you want to display a message in a Label then go ahead. You obviously know how to display text in a Label and you obviously know how to use an If statement to determine the state of the ProgressBar so what exactly is the issue?
Re: Show message while progressbar is processing
I have the same problem...
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(3)
If ProgressBar1.Value = ProgressBar1.Maximum Then
Timer1.Stop()
End If
If ProgressBar1.Value & ("1") Then
Label1.Text = "Status: Start"
End If
If ProgressBar1.Value & ("50") Then
Label1.Text = "Status: Bla"
End If
If ProgressBar1.Value & ("100") Then
Label1.Text = "Status: Finished"
End If
End Sub
With this code the Label only shows :" Status: Finished"
How would be the correct syntax? :)
Re: Show message while progressbar is processing
I think the problem the both of you are having is this:
Everything is running on the same thread, which means that the UI is not updating while the progress bar is working.
Try running the progress bar as a background worker
http://msdn.microsoft.com/en-CA/libr...undworker.aspx
I dont know much on the topic but hopefully someone else chimes in
Re: Show message while progressbar is processing
Quote:
Originally Posted by
Crzyrio
I think the problem the both of you are having is this:
Everything is running on the same thread, which means that the UI is not updating while the progress bar is working.
Try running the progress bar as a background worker
http://msdn.microsoft.com/en-CA/libr...undworker.aspx
I dont know much on the topic but hopefully someone else chimes in
I am pretty sure, that there is a more easy way than that, but thanks anyway.
Propably there is someone else who could help me/us with that problem?
Re: Show message while progressbar is processing
Quote:
Try running the progress bar as a background worker
Well, you'd run the process as the background worker and keep the progress bar on the UI actually. I doubt that either case demands this approach but even if it does the programming of the label will be the same and it's difficult to see why there should be any problems with it.
In cocobrico's case it's this ...
If ProgressBar1.Value & ("1") Then
... which is the problem. Makes no sense. It really is very simple ...
vb.net Code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(2)
Select Case ProgressBar1.Value
Case Is < 20
Label1.Text = "Give me a chance, I've only just started!"
Case 20 To 39
Label1.Text = "Now we're getting somewhere!"
Case 40 To 70
Label1.Text = "Better finish that coffee. Won't be long now."
Case 71 To 98
Label1.Text = "Nearly there."
Case Else
Label1.Text = "All done!"
Timer1.Stop()
End Select
End Sub
Having said that I'm not a fan of timer based progress bars not least because they are inherently inaccurate.
Re: Show message while progressbar is processing
Quote:
Originally Posted by
dunfiddlin
Well, you'd run the process as the background worker and keep the progress bar on the UI actually. I doubt that either case demands this approach but even if it does the programming of the label will be the same and it's difficult to see why there should be any problems with it.
In cocobrico's case it's this ...
If ProgressBar1.Value & ("1") Then
... which is the problem. Makes no sense. It really is very simple ...
vb.net Code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(2)
Select Case ProgressBar1.Value
Case Is < 20
Label1.Text = "Give me a chance, I've only just started!"
Case 20 To 39
Label1.Text = "Now we're getting somewhere!"
Case 40 To 70
Label1.Text = "Better finish that coffee. Won't be long now."
Case 71 To 98
Label1.Text = "Nearly there."
Case Else
Label1.Text = "All done!"
Timer1.Stop()
End Select
End Sub
Having said that I'm not a fan of timer based progress bars not least because they are inherently inaccurate.
Thank you!! :-) It's working like charm!
Re: Show message while progressbar is processing
ProgressBar1.Value & ("1") means what? The ampersand means: Put two strings together, so if the value of the ProgressBar happens to be 25 then 25 & "1" = "251" so what does the If statement:means, well not much... Since you have Option Strict set to Off it means: "251" is not false so it must be true...