LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Why doesn't status bar update consistently?

Based on an example in Walkenbach's book [1], the
following code is intended to update the status bar every
second or so. Sometimes the status bar is updated as
expected. Sometimes the updates "stall" until the "done"
update. The point at which the updates "stall" varies. I
have tried intervals of 1, 2 and 3 sec, all with the same
erratic results.

Any idea why the status bar update "stalls", and why the
"stall" is erratic?


Sub timeit()
limitTime = 20: interval = 1
Application.StatusBar = _
"00:00 Start limit=" & limitTime & " intvl=" & interval
startTime = Timer: lastTime = startTime
n = 0: nLoop = 0
Do
curTime = Timer: nLoop = nLoop + 1
If curTime - lastTime = interval Then
lastTime = curTime: n = n + 1
Application.StatusBar = _
Format(lastTime - startTime, "00:00") & _
" n=" & n & "/" & nLoop & _
" limit=" & limitTime & " intvl=" & interval
End If
Loop While curTime - startTime < limitTime
Application.StatusBar = _
Format(curTime - startTime, "00:00") & _
" n=" & n & "/" & nLoop & " Done intvl=" & interval
End Sub


The macro continues to run when the update "stalls".
nLoop averages 44.5e6 +/- 0.2% independently of the
interval, even when I set the interval to 30 so that there
are no updates. (Of course, the average nLoop count
will vary from system to system.)

My guess is that the status bar updates are asynchronous,
and the macro fails to yield the CPU long enough for it to
occur. My guess is that when it works, it is because higher
priority interrupts (processes or hardware interrupts) allow
the system to complete the status bar update before
resuming execution of the macro.

But I am surprised that Walkenbach does not hint at the
possibility in his example. That makes me suspicious of my
interpretation (guess) of the problem, and I wonder if it is
unique to my system -- perhaps symptomatic of other erratic
system misbehavior.

PS: I am using Excel 2003.


-----
[1] "Excel 2003 Power Programming with VBA", p. 474.
Walkenbach writes:

You can, of course, update the status bar while your
macro progresses. For example, if you have a variable
named Pct that represents the percent completed, you
can write code that periodically executes a statement
such as this:
Application.StatusBar = "Processing..." & Pct & "% Completed"
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to calculate month of last status update Chris Excel Worksheet Functions 6 November 1st 08 01:46 AM
reuest formula for auto update status & status date PERANISH Excel Worksheet Functions 5 June 2nd 08 04:26 PM
Says can't update links, but status ok meg Excel Discussion (Misc queries) 0 February 21st 08 03:13 PM
CPU Usage consistently above 75% hparteep Excel Discussion (Misc queries) 1 October 27th 05 02:56 PM
Need a msg box that displays time status or loading status havocdragon Excel Programming 2 April 2nd 05 05:29 PM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"