Progress bar that tracks actual progress??

J

JuanManuel

I just finished implementing and testing my first progress bar. I got the
code from this link:

word.mvps.org/faqs/Userforms/CreateAProgressBar.htm

I was dissappointed though!! As far as I understand how the progress bar
works and based on my timing results, the progress bar does not track actual
progress, it simply fills up a bar independently of the actual progress of a
subroutine. In the end, you get a slower program that does nothing to keep
the user informed of the actual progress.

Is there a way to code a real progress bar, one that actually tracks the
actual progress of a subroutine? Even if it does it with an error margin?

Thank you,

Juan
 
S

StevenM

To: Juan,

Is there a reason why you don't want to use the Status bar?

I often use something like:
For i = 1 to nNumber
Application.StatusBar = nNumber & ":" & i
'Other stuff here
Next i

Then the status bar will tell me how many items needs to be processed and
how close it is to getting done.

One drawback I've encounted when using this is that if I switch windows
during this process and then switch back, the status bar does not work.
Perhaps that is the reason you've opted for the progress bar?

Steven Craig Miller
 
J

Jonathan West

JuanManuel said:
I just finished implementing and testing my first progress bar. I got the
code from this link:

word.mvps.org/faqs/Userforms/CreateAProgressBar.htm

I was dissappointed though!! As far as I understand how the progress bar
works and based on my timing results, the progress bar does not track
actual
progress, it simply fills up a bar independently of the actual progress of
a
subroutine. In the end, you get a slower program that does nothing to keep
the user informed of the actual progress.

Is there a way to code a real progress bar, one that actually tracks the
actual progress of a subroutine? Even if it does it with an error margin?

Thank you,


Well, you have to define how to measure that progress. The following code in
the article is purely for demonstration purposes, and you have to replace it
with your own which not only performs the actions you need but also provides
a measure of the progress in doing so

For i = 1 To 10000

' Create 10000 dummy paragraphs in ActiveDocument
ActiveDocument.Paragraphs.Last.Range. _
Text = "Test Paragraph " & i & vbCr

' Increase size of Label1 incrementally
Label1.Width = i / 50

' Repaint allows Label1 to display as it is enlarging
Frame1.Repaint

Next i
 
L

leightonwalter

Thanks for the additional information. In my case, I want to use the scroll
bar to track a rather complex text-formatting process -- hundreds of lines of
code, lots of text-file access, etc. Don't want to put all this inside the
userform's code, so is there any way to feed progress information to the
userform?

Thanks for any help you can offer.

L.
 
L

leightonwalter

Also, I have another process that involves querying a database through a web
page. The query is slow, up to a minute, and I'd like to show "progress"
there, though I can't measure it. Do the query, then the user just has to
wait. Would like a statusbar or something that would tick along, at least
showing the user that *something* was happening. Trouble is, once I start the
process, the VBA program stops until the process is done -- I can't kick off
timer. Similarly, if I start a faux-timer, I can't start the query until the
timer's done. Need to have both running simultaneously. Any options?

Thanks for any help anyone can offer.

L.
 
K

Karl E. Peterson

leightonwalter said:
Thanks for the additional information. In my case, I want to use the scroll
bar to track a rather complex text-formatting process -- hundreds of lines of
code, lots of text-file access, etc. Don't want to put all this inside the
userform's code, so is there any way to feed progress information to the
userform?

Create a public property for the form.

Public Property Let Progress(ByVal PercentDone As Long)
' Set progress bar value here
End Property
 
K

Karl E. Peterson

leightonwalter said:
Also, I have another process that involves querying a database through a web
page. The query is slow, up to a minute, and I'd like to show "progress"
there, though I can't measure it.

A quandary, yep.
Do the query, then the user just has to wait.

That's the cost of relying on code you didn't write.
Would like a statusbar or something that would tick along, at least
showing the user that *something* was happening.

Animations are a classic answer to this problem. Remember the hourglass cursor in
Windows 3x? Then, the filecopy animation in Win95? Crude, but apparently
entertaining.
Trouble is, once I start the
process, the VBA program stops until the process is done -- I can't kick off
timer. Similarly, if I start a faux-timer, I can't start the query until the
timer's done. Need to have both running simultaneously. Any options?

Hmmmmm, you might want to try the timer objects I wrote --
http://vb.mvps.org/samples/TimerObj -- I don't believe this limitation would be in
effect but would be interested in finding out if it is. (I know it's not in
standalone VB.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top