Macro (SVB) Programs Example - Displaying a Progress Bar

It is sometimes desirable to indicate the progress of lengthy sequential computations by displaying a progress bar, the same kind of progress bar that is used throughout Statistica when large data files are analyzed. Here is a program that implements the progress bar in the random number generator program:

Option Base 1Sub MainDim n As Long,
i As Long n=1000
' Create and dimension the spreadsheet object 
Dim s As New Spreadsheet
' Set the size of the object s.SetSize(n,2)
' Set up a progress bar 
Dim pb As ProgressBar 
Set pb = AddProgressBar("Generating random numbers", 1, n)
' Assign the random values 
For i = 1 To n
' Update the progress bar pb.CurrentCounter = i 
s.Value(i,1) = Rnd(1) 
s.Value(i,2) = RndNormal(1)Next i
' Close the progress bar Set pb = Nothing
' Set the variable names s.VariableName(1) = "Uniform" 
s.VariableName(2) = "Normal" s.Visible = True
End Sub