R
ripamonti
Hi to everyone,
I m trying to use this samle progress bar with my code(it is a
montecarlo simulation programme). I don't really know how to connect
this program to my loop code(montecarlo).
do you have some suggestions?
Sub ProgressBarSimpleDemo2()
Dim sb As clsProgressBar, i As Long
Dim Counter As Long
Dim NumRows As Long, NumCols As Integer
Dim r As Long, c As Integer
Dim Total As Long
Set sb = New clsProgressBar ' create a new progress bar
With sb
.Show "Entering random numbers", vbNullString, 0 ' display the
progress bar
.ProgressBarFG_RGB = RGB(255, 0, 0) 'set foreground to red
End With
' Generate random numbers
Range("A2:IV65536").Clear
Counter = 0
NumRows = 1000
NumCols = 50
Total = NumRows * NumCols
For r = 1 To NumRows
For c = 1 To NumCols
Counter = Counter + 1
Cells(r + 1, c) = Int(Rnd() * 500)
' update the progress bar?
If Counter Mod 50 = 0 Then sb.PercentComplete = (Counter /
Total) * 100
Next c
Next r
Set sb = Nothing ' remove the progress bar
MsgBox Total & " random numbers were generated."
Range("A2:IV65536").Clear
End Sub
I m trying to use this samle progress bar with my code(it is a
montecarlo simulation programme). I don't really know how to connect
this program to my loop code(montecarlo).
do you have some suggestions?
Sub ProgressBarSimpleDemo2()
Dim sb As clsProgressBar, i As Long
Dim Counter As Long
Dim NumRows As Long, NumCols As Integer
Dim r As Long, c As Integer
Dim Total As Long
Set sb = New clsProgressBar ' create a new progress bar
With sb
.Show "Entering random numbers", vbNullString, 0 ' display the
progress bar
.ProgressBarFG_RGB = RGB(255, 0, 0) 'set foreground to red
End With
' Generate random numbers
Range("A2:IV65536").Clear
Counter = 0
NumRows = 1000
NumCols = 50
Total = NumRows * NumCols
For r = 1 To NumRows
For c = 1 To NumCols
Counter = Counter + 1
Cells(r + 1, c) = Int(Rnd() * 500)
' update the progress bar?
If Counter Mod 50 = 0 Then sb.PercentComplete = (Counter /
Total) * 100
Next c
Next r
Set sb = Nothing ' remove the progress bar
MsgBox Total & " random numbers were generated."
Range("A2:IV65536").Clear
End Sub