| ProgressBar |
| |
| |
| When beginning a long task, make the ProgressBar visible. Set its Min and Max properties to represent the task. |
| As the task progresses, set the ProgressBar's Value property to indicate the amount of the task completed. |
| When the task is finished, set Visible to false for the ProgressBar. |
| |
| Private Sub cmdPerformTask_Click() | |
| cmdPerformTask.Enabled = False | Don't let the user click this till we are done with this task. |
| MousePointer = vbHourglass | |
| pbTaskProgress.Value = pbTaskProgress.Min | Start the progress bar at zero. |
| pbTaskProgress.Visible = True | |
| tmrTaskTimer.Enabled = True | Enable the timer to start the long task. |
| End Sub | |
| |
| Private Sub Form_Load() | |
| cmdPerformTask.Caption = "Perform Task" |
| pbTaskProgress.Visible = False |
| pbTaskProgress.Align = vbAlignBottom |
| pbTaskProgress.Min = 0 |
| pbTaskProgress.Max = 100 |
| tmrTaskTimer.Interval = 100 |
| tmrTaskTimer.Enabled = False | |
| End Sub | |
| |
| Private Sub tmrTaskTimer_Timer() | |
| pbTaskProgress.Value = pbTaskProgress.Value + 10 | Increase the ProgressBar's value. |
| If pbTaskProgress.Value >= pbTaskProgress.Max Then | If we're done, reenable the button. |
| pbTaskProgress.Visible = False | |
| cmdPerformTask.Enabled = True | |
| tmrTaskTimer.Enabled = False | |
| MousePointer = vbDefault | |
| End If | |
| End Sub | |
| |