|
|
Title | Use a ProgressBar with a long task without timer |
Keywords | progress bar, ProgressBar, long task, status |
Categories | Software Engineering, Controls |
|
|
When beginning a long task, make the ProgressBar visible. Set its Min and Max properties to represent the task and perform the task. The task periodically updates the ProgressBar.
|
|
Private Sub cmdPerformTask_Click()
Dim i As Integer
Dim j As Long
' Don't let the user click this till we
' are done with this task.
cmdPerformTask.Enabled = False
MousePointer = vbHourglass
DoEvents
' Start the progress bar at zero.
pbTaskProgress.Value = pbTaskProgress.Min
pbTaskProgress.Visible = True
DoEvents
' Perform the long task.
For i = 1 To 100
' Do something long.
For j = 1 To 500000
Next j
' Increase the ProgressBar's value.
pbTaskProgress.Value = i
Next i
' Reenable the button.
pbTaskProgress.Visible = False
cmdPerformTask.Enabled = True
MousePointer = vbDefault
End Sub
|
|
|
|
|
|