|
-
Feb 23rd, 2000, 04:50 AM
#1
Thread Starter
Lively Member
can anyone please give me some sample code on how progress
bars work as im trying to learn how they work

many thanx
johnny
-
Feb 23rd, 2000, 05:16 AM
#2
In order for you show the progress of something you have to calculate it. Progressbar has 3 main properties that you would have to worry about: Min, Max and Value.
These 3 properies are needed for you in order to show the progress status. So, let's say you have a loop from 1 to 25000, which we will show the status of.
Code:
Private Sub Command1_Click()
Dim i As Integer
With ProgressBar1
.Min = 0 'These values are default
.Max = 100 'but I'm using them, so you'll know what they are for
For i = 1 To 25000
.Value = (i / 25000) * 100
Next
End With
End Sub
As you can see all I'm calculating is a percentage, i.e. (Counter / Maximum) * 100
Of course, you can use another example like this:
Code:
Private Sub Command1_Click()
With ProgressBar1
.Min = 0
.Max = 25000
Do Until .Value = .Max
.Value = .Value + 1
Loop
End With
End Sub
With the first example it is a lot more generic, that means no matter how many times the loop executes, the percentage will be recalculated accordingly
Edited by Serge on 02-23-2000 at 05:18 PM
-
Feb 23rd, 2000, 08:14 AM
#3
Hyperactive Member
Johnny, here's a nifty trick for using a progress bar to chart the progress when looping through a recordset. That is usually what I use them for. Here you use the recordset properties to create the Min, Max, and Value properties, like Serge showed you above.
Code:
With ProgressBar1
.Value = 0
.Visible = True
.Max = rsMyRecordset.RecordCount
End With
If rsMyRecordset.EOF = False And rsMyRec.BOF = False Then
rsMyRecordset.MoveFirst
Do Until rsMyRecordset.EOF
ProgressBar1.Value = rsMyRecordset.AbsolutePosition + 1
'insert whatever you want the loop to do here
rsMyRecordset.MoveNext
Loop
End Sub
With ProgressBar1
.Value = ProgressBar1.Max
.Visible = False
.Value = 0
End With
The above example is for an ADO recordset. With DAO the structure would be the same, only the syntax of the recordset properties is a little different.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|