View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Brian Murphy Brian Murphy is offline
external usenet poster
 
Posts: 126
Default Timer causes run-time error '6' overflow

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





On Dec 11, 10:03*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Brian,

Post your code?

Bernie
MS Excel MVP

"Brian Murphy" wrote in message

...

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