OnTime, TimveValue to repeat every 0.2 sec?

  • Thread starter Thread starter gs2000
  • Start date Start date
G

gs2000

A statement like:
Application.OnTime Now + TimeValue("00:00:15")
can be used to delay executing something by 15 seconds.

If I wanted to use a delay that is less than a second, what do I do?

To be more specific - I am writing something in VBA in Excel 2000 wher
the program communicates with a device connected to Com Port. I wan
to send out a command and receive data back every 0.2 seconds.

Look forward to your help, thanks
 
gs2000

Sorry, one second is the smallest time OnTime will accept.

I don't know if this will work, but you might try Wait.

Dim endtime As Date

endtime = Now + TimeValue("00:00:05")

Do
Application.Wait Now + (1 / 24 / 60 / 60 / 100 * 2)
'run code
Loop Until Now = endtime

Wait may have the same restrictions as OnTime, but it's worth a shot.
 

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


Back
Top