How The Standalone Progress Indicator Works

When you execute the ShowDialog procedure, the Label object's width is set to 0. Then the Show method of the UserForml object displays the UserForm (which is the progress indicator). When the UserForm is displayed, its Activate event is triggered, which executes the Main procedure. The Main procedure periodically updates the width of the label. Notice that the procedure uses the Repaint method of the UserForm object. Without this statement, the changes to the label would not be updated. Before the procedure ends, the last statement unloads the UserForm.

To customize this technique, you need to figure out how to determine the percentage completed and assign it to the PctDone variable. This will vary, depending on your application. If your code runs in a loop (as in this example), determining the percentage completed is easy. If your code is not in a loop, you might need to estimate the progress completed at various points in your code.

0 0

Post a comment