Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Fraction of seconds

I have set up a timer as follows:

Dim alertTime
alertTime = Now + TimeValue("00:00:01")
Application.OnTime alertTime, "procedure"

This does what I want, except I require time intervals less than one second.

Is this possible?

Art


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Fraction of seconds

Simplest for if you just want a little wait is use the Sleep API.
Put this at the top of your normal module:

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

And use it like this:

Sleep 300 'wait 300 milli-seconds

procedure


RBS



"ArthurJ" wrote in message
...
I have set up a timer as follows:

Dim alertTime
alertTime = Now + TimeValue("00:00:01")
Application.OnTime alertTime, "procedure"

This does what I want, except I require time intervals less than one
second.

Is this possible?

Art



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Fraction of seconds


Hello Art,

You have 2 choices for more precision. The VBA Timer will provide yo
with accuracy to 1/100 of a second. The API timer will provide accurac
to 1/1,000 of a second.

The VBA Timer is easy yo use but has to be used in a loop. The AP
Timer is more a little more complex but can runs unattended in th
background. I am going to skip posting the API Timer code due to it
length. If you decide you need the API Timer, let me know in your nex
post and I will post the code separately.

VBA Timer example...

Code
-------------------

Sub TimeLoop()

Delay = 0.02
StartTime = Timer

Do While Timer < StartTime + Delay
DoEvents
'Your code goes in here
Loop

End Sub

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=56184

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Thanks RBS & Leith (eom)


Reply
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
Show fraction as fraction even if answer is 1 Vin Sukhadia Charts and Charting in Excel 1 December 2nd 09 07:51 PM
Text fraction to fraction format brownti via OfficeKB.com Excel Worksheet Functions 1 February 1st 08 02:38 PM
How do I change fraction to fraction characters? cmcqueary2806 Excel Worksheet Functions 1 November 2nd 06 09:58 PM
Converting Julian Seconds with a macro to replace old seconds data Keldair Excel Discussion (Misc queries) 2 February 18th 06 12:09 AM
Convert "Time Interval" in "hours : minutes : seconds" to seconds Ianukotnorth New Users to Excel 7 May 8th 05 08:11 PM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"