Click to See Complete Forum and Search --> : ProgressBar, Please help me
i want to display a ProgressBar while read a table. i'm using ProgressBar (mscomctl.ocx.
TIA
Negative0
Nov 16th, 2000, 02:34 PM
You could do something like this:
Dim inc As Double
Dim NumOfIterations As Integer
inc = 0
ProgressBar1.Value = 0
NumOfIterations = 12000
inc = 100 / NumOfIterations
For x = 1 To NumOfIterations
If ProgressBar1.Value + inc < 100 Then
ProgressBar1.Value = ProgressBar1.Value + inc
If ProgressBar1.Value Mod 5 = 0 Then
Me.Refresh
End If
Else
ProgressBar1.Value = 100
End If
Next
This code increments the Progressbar based on the number of iterations you have for your loop. Basically for your problem you will want to figure out how many iterations you have and then calculate your increment. Once you have your increment you just increment your progress bar each time through the loop. The
If ProgressBar1.Value Mod 5 = 0 Then
Me.Refresh
End If
Only refreshes the screen twenty times, because refreshing is a costly process.
ender_pete
Nov 16th, 2000, 02:38 PM
what do you want the progressbar to do?
do you want to the progressbar to track the progress
of the table loading to a recordset, or the progress of filling a recordset... be more specific....
here is code to a form i use as a global status indicator
all i do is load the form set the variables in the form and then call the changevalue function on the form...
use the increment function if you want to increment
a certain multiple of times
Public strProcess As String
Public sglTotalValue As Single
Public sglStep As Single
Public Sub Form_GetStepValue(lngTotalValue As Long)
If lngTotalValue <= 0 Then lngTotalValue = 1
sglStep = 32767 / lngTotalValue
End Sub
Public Sub Form_ChangeValue()
sglTotalValue = sglTotalValue + sglStep
If sglTotalValue <= 32767 Then _
SBar.Value = CInt(sglTotalValue)
End Sub
Public Sub Form_Increment(lngSpecInc As Long)
sglTotalValue = sglTotalValue + sglStep * lngSpecInc
If sglTotalValue <= 32767 Then _
SBar.Value = CInt(sglTotalValue)
End Sub
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.