Windows Develop Bookmark and Share   
 index > Windows Forms General > Using a progress bar to show the progress of several subroutines
 

Using a progress bar to show the progress of several subroutines

hello,

I wish to use a progress bar to show the progress of several subrotines that run after a button click event. Any help would be appreciated.

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click

MCCalc()

WetDenCalc()

OSCalcs()

calcCurve()

omcCalc()

showValues()

End Sub


LuckyPhil78  Wednesday, May 13, 2009 10:03 AM
Hi!

Drag a progressbar to your form. In its properties pane set Maximum = 90
Set Step property = 15

In each Subroutine, Before
End Sub

Write-

ProgressBar1.PerformStep()

I think your functions are going to get completed within no time, so if you want to show increment slowly then put
Threading.Thread.Sleep(100)
just before PerformStep()

This is one way to do it. Few other possibilities are there to show smooth progress. Or you can use Full ProgressBar for each of that subroutine.. like
Call MCCalc()
Display progress for that sub by fully using Progressbar
End MCCalc

Call WetDenCalc()
Reset ProgressBar
Show Progress
End Sub

like that...








Thanks

- Omie
  • Marked As Answer byLuckyPhil78 Thursday, May 14, 2009 11:50 AM
  •  
Omie  Wednesday, May 13, 2009 10:36 AM
Hi!

Drag a progressbar to your form. In its properties pane set Maximum = 90
Set Step property = 15

In each Subroutine, Before
End Sub

Write-

ProgressBar1.PerformStep()

I think your functions are going to get completed within no time, so if you want to show increment slowly then put
Threading.Thread.Sleep(100)
just before PerformStep()

This is one way to do it. Few other possibilities are there to show smooth progress. Or you can use Full ProgressBar for each of that subroutine.. like
Call MCCalc()
Display progress for that sub by fully using Progressbar
End MCCalc

Call WetDenCalc()
Reset ProgressBar
Show Progress
End Sub

like that...








Thanks

- Omie
  • Marked As Answer byLuckyPhil78 Thursday, May 14, 2009 11:50 AM
  •  
Omie  Wednesday, May 13, 2009 10:36 AM
are you planning on threading those functions or running them consecutively? If the latter, then you just need to throw a dialog up with a progress bar on it and call updates from your calculations. If you use this method, since the gui thread will be blocked, you will need to hit application.doevents a lot to keep the gui updating.

the better way to do it though is to thread the calculations and simply fire events back to update the progress bar as you go

Allen Anderson - Architect http://www.richercomponents.com - (WinForm And Asp.net Controls)
Allen Anderson  Thursday, May 14, 2009 8:38 AM

You can use google to search for other answers

Custom Search

More Threads

• DatagridView CheckBox Select Problem .
• Extending print dialog and using printhookproc()
• Active Hosts on Network
• How to Extract the Date From Datetime
• Changing component size on windows resize
• how we can show a message box with 2 chois OK and cancel
• arrays of classes in C++ windows forms
• Reconnect to web service
• How To Detect Shift+Arrow Key
• Blinking Text