Timer causes run-time error '6' overflow

  • Thread starter Thread starter Brian Murphy
  • Start date Start date
B

Brian Murphy

I'm using Timer to profile some code. For no reason I can think of
I'm getting overflow when trying to call Timer to get the time value.

Why would this happen?
If I enter debug mode and press continue, the error goes away.

Thanks,

Brian
 
It's a really long bit of code.
I've used Timer quite often to profile code. I've never had this
problem before.
The way I generally use it is like this:

Dim startTime as Double
startTime = Timer

.... code being timed goes here ...

Debug.Print (Timer - startTime)

The overflow happens on the second call to Timer. I tried all
different manners of data types and such, with no luck. If I enter
debug mode and press F5, the code continues running with no problem
until it comes back to this same line again.

It just doesn't make any sense.

After some more work on this I think I've got a clue.
I found that if I move the .Print line up far enough it will run.
The error starts right after a VBA call to a routine in compiled DLL
(it's in Fortran).
The error will stop happening if the Timer call is after a line that
puts data in a cell on a worksheet.

Somehow the call to the DLL seems to lock up the Timer, but putting
data onto a worksheet unlocks it.

Could this be possible?

Brian
 
Brian,

I'm sorry, I have never run into the kind of problem you describe.

HTH,
Bernie
MS Excel MVP


It's a really long bit of code.
I've used Timer quite often to profile code. I've never had this
problem before.
The way I generally use it is like this:

Dim startTime as Double
startTime = Timer

.... code being timed goes here ...

Debug.Print (Timer - startTime)

The overflow happens on the second call to Timer. I tried all
different manners of data types and such, with no luck. If I enter
debug mode and press F5, the code continues running with no problem
until it comes back to this same line again.

It just doesn't make any sense.

After some more work on this I think I've got a clue.
I found that if I move the .Print line up far enough it will run.
The error starts right after a VBA call to a routine in compiled DLL
(it's in Fortran).
The error will stop happening if the Timer call is after a line that
puts data in a cell on a worksheet.

Somehow the call to the DLL seems to lock up the Timer, but putting
data onto a worksheet unlocks it.

Could this be possible?

Brian
 
Back
Top