To use a progressbar you need to know the range of the task. In this case you need to know the depth ahead of time of the recursion. Which I don't believe you will.
So there is no real way to usee a progress bar to show the actual progress time.
However there is another solution that may be useful, It is to use the progress bar as a feedback that the function is working. The best way is to call a "Increment PB" function which adds one to the value of the progressbar (pb) in this function you check if it will reach the max and if so, reset it to 1 and start the pb over again. It is used on many copy processes in windows environment just to show that the process is still busy and working and not hung.
Code for this would look like
private sub IncrPB()
if pb.value + 1 = pb.max then
pb.value = 1
else
pb.value = pb.value +1
endif
doevents ' used to allow the pb to update itself
end sub
Main Topics
Browse All Topics





by: g0rathPosted on 2004-01-12 at 08:34:44ID: 10095928
' GridQSort from http://www.andreavb.com/ti p120004.ht ml
, Column), med_value, NumComp, Ascending) >= 0 , Column), med_value, NumComp, Ascending) < 0
Public Sub GridQSort(Grid As MSFlexGrid, ByVal Column As Integer, ByVal min As Long, _
ByVal max As Long, ByVal Ascending As Boolean, ByVal NumComp As Boolean)
Dim tmp() ' when swap rows keep copy here
ReDim tmp(Grid.Cols)
Dim med_value, hi As Long, lo As Long, i As Integer
If min >= max Then Exit Sub
med_value = Grid.TextMatrix(min, Column)
SaveRow Grid, min, tmp
lo = min
hi = max
Do
Do While Compare(Grid.TextMatrix(hi
hi = hi - 1
If hi <= lo Then Exit Do
Loop
If hi <= lo Then
RestoreRow Grid, lo, tmp
Exit Do
End If
For i = 0 To Grid.Cols - 1
Grid.TextMatrix(lo, i) = Grid.TextMatrix(hi, i)
Next i
lo = lo + 1
Do While Compare(Grid.TextMatrix(lo
lo = lo + 1
If lo >= hi Then Exit Do
Loop
If lo >= hi Then
lo = hi
RestoreRow Grid, hi, tmp
Exit Do
End If
For i = 0 To Grid.Cols - 1
Grid.TextMatrix(hi, i) = Grid.TextMatrix(lo, i)
Next i
Loop
GridQSort Grid, Column, min, lo - 1, Ascending, NumComp
GridQSort Grid, Column, lo + 1, max, Ascending, NumComp
End Sub
Private Function Compare(ByVal X, ByVal Y, ByVal NumComp As Boolean, _
ByVal Ascending As Boolean) As Integer
Dim b As Integer
If NumComp Then
X = CDbl(X)
Y = CDbl(Y)
End If
If X > Y Then b = 1
If X < Y Then b = -1
If X = Y Then b = 0
If Not Ascending Then b = -b
Compare = b
End Function
Private Sub RestoreRow(Grid As MSFlexGrid, ByVal RowNum As Long, tmpArr())
Dim i As Long
For i = 0 To Grid.Cols - 1
Grid.TextMatrix(RowNum, i) = tmpArr(i)
Next i
End Sub
Private Sub SaveRow(Grid As MSFlexGrid, ByVal RowNum As Long, tmpArr())
Dim i As Long
For i = 0 To Grid.Cols - 1
tmpArr(i) = Grid.TextMatrix(RowNum, i)
Next i
End Sub
' This is the code I'm trying to modify