|
-
Mar 21st, 2013, 05:50 AM
#1
Thread Starter
Junior Member
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!
-
Mar 21st, 2013, 08:34 AM
#2
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?
-
Apr 25th, 2013, 01:04 PM
#3
New Member
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?
-
Apr 25th, 2013, 01:20 PM
#4
Addicted Member
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
-
Apr 25th, 2013, 01:49 PM
#5
New Member
Re: Show message while progressbar is processing
 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?
-
Apr 25th, 2013, 01:53 PM
#6
Re: Show message while progressbar is processing
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.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Apr 25th, 2013, 02:05 PM
#7
New Member
Re: Show message while progressbar is processing
 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!
-
Apr 25th, 2013, 02:37 PM
#8
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|