Click to See Complete Forum and Search --> : Clock problem when using sleep function


itayc1
April 29th, 2006, 12:28 PM
Hello all,

I am running a simple clock ( in a textbox ) which runs continually
on screen.
My problem is that when I use the Threading.Thread.Sleep(3000) in one of my functions (not related to the clock at all ), the clock stops for 3 seconds.

I would like to pause the function only and not the entire project.
I tried creating a simple loop but it is not accurate.

for i=1 to 200000 ' will sleep for appr 3 sec
application.doevents()
next i

Any other ideas?

Thanks,

Itay.

Craig Gemmill
April 29th, 2006, 01:37 PM
The correct way to do this is with multi-threading.

You will almost never have correct results when using the for/next method.