Results 1 to 4 of 4

Thread: Progress Bar makes my progress slower ??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Post

    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



  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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.
    Code:
    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

  3. #3
    Guest

    Post

    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
    Web Sites:The Blue Link My Home Page

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    *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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width