Built-in Tools

Whoa Progress Bar

The progress bar is a built-in way to "distract users" while a longer-than-usual script is running.

Disadvantages to using Progress Bar
  • Marginally increase complexity of your codebase (more lines of code)
  • Marginally increase overall time it takes to run the script.
When to use Progress Bar
  • People do not mind waiting for a "slow elevator" when there are mirrors in the lobby.
  • Progress bars provides a sort of "mirror" to entertain and inform them.
Progress Bar Example (Simple)

Simple example where there is just one level of bar.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Private Sub DEMO_PROGRESS_BAR_SIMPLE()
    
    ' Get the progress bar instance
    Dim pbar As clsProgressBar
    Set pbar = GetWhoaProgressBar_AndDisplay("Whoa Progress Bar - Test Drive")
    
    
    ' Provide the total number of steps to the progress bar
    ' This is needed for the bar to calculate "how much to advance" each time
    ' pBar.IncrementStep() is called
    
    Const TOTAL_STEPS As Long = 5
    pbar.StartActivity TOTAL_STEPS, "Starting up something"
    
    Dim count As Long
    For count = 1 To TOTAL_STEPS
        
        ' calling pbar.IncrementStep() advances the bar forward
        ' You can also update the text (that appears under the bar) as a way
        ' to inform user where they are in the overall process
        pbar.IncrementStep "Running step: " & count
        Call WhoaSleepHard(NumberSeconds:=1.05)
        
        ' On the second iteration, change the bar color to red
        If count = 2 Then
            
            ' Change the bar COLOR
            pbar.ChangeBarColor vbRed
            
            ' Change the bar TEXT
            ' Sometimes this is useful when you specifically DON'T want to
            ' call pbar.IncrementStep (which would advance the bar), but still want
            ' to emit some info to the user.
            
            pbar.ChangeActivityText "Changing bar color to RED!"
            
            ' Pause a moment
            ' Without a pause, the "changed bar" text would be overwritten instantly.
            Call WhoaSleepHard(NumberSeconds:=0.55)
        End If
        
    Next count
    
    ' Shutdown the bar
    ' This may not always be necessary, but it's never harmful
    Call pbar.Shutdown
End Sub
Progress Bar Example (Advanced)

An advanced use case is when a process involves multiple procedures. In this situation the number of steps may not be knowable in advance.

Will add an Advanced Progress Bar code example here in the future.