Click to See Complete Forum and Search --> : Progress Bar makes my progress slower ??
David Laplante
Nov 25th, 1999, 02:32 AM
Hi,
I was wondering why when I put a progress bar, my process takes twice as long... I mean I know that it has to redraw and all but Am I doing something wrong.... ?
.min = .value = 0
.max = recordset.recordcount
do until recordset.eof
'Do something
.value = .value + 1
recordset.movenext
loop
Aaron Young
Nov 25th, 1999, 12:04 PM
The Progress bar is a fairly large object, for what it does, and has a host of fancy tweaks you can do to it. This all comes at a price, Speed.
Even if you don't make use of those features avaiable, you still have the Objects overhead.
What you could do, is only update the Progress bar at intervals, ie, instead of incrementing it by 1 every loop, increment it by 10 every 10 loops, increasing the speed 10 fold.
Alternatively, the method I prefer is to create my own Progress bar using a Simple Picturebox, eg.
Private Sub Command1_Click()
Picture1.Tag = 1000
For i = 0 To 1000
UpdateProgress (i)
DoEvents
Next
MsgBox "Done"
End Sub
Private Sub UpdateProgress(ByVal iValue As Long)
With Picture1
If iValue = 1 Then .Cls
Picture1.Line (0, 0)-Step((.ScaleWidth / .Tag) * iValue, .ScaleHeight), vbBlue, BF
End With
End Sub
Set the Tag Property to the Max Value, then Call the UpdateProgress Function passing the Current Value.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
Hmmm...I must agree with Aaron there, progress bars are like splash screens...their purpose is to give the user some thing to keep them occupied and make them think that your program is working faster, but often it's the opposite - they're as slow as hell.
The fake progress bar made from two picture boxes is a good idea though...I've used it a few times myself, however the picture box is also a rather nasty memory hog...you'd be better using the same technique, but with two of the "Shape" object instead.
------------------
Matthew Ralston
E-Mail: m.ralston@mediavault.co.uk
ICQ:31422892 (http://195.89.158.103/icq.html)
Web Sites:The Blue Link (http://195.89.158.103) My Home Page (http://mralston.cjb.net)
Crazy D
Nov 25th, 1999, 04:18 PM
*everything* you do during a long process slows that process down. But, indeed, it gives the idea it goes faster since you can see it's busy... and you can see it's busy so the user wont think the program is hanging.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.