View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gum Gum is offline
external usenet poster
 
Posts: 30
Default VBA adding time in milliseconds

A type of timer where the instance of an event is captured, say t and after t
+ Delta t, where deta t is a in milliseconds, an event is triggered. So I
will use a comparator:
if time t plus delta t time t Then
triggerevent
....
if now() is an approximation to the nearest second, I can see the problem
with my formulation. I am also looking for a solution with the minimum
footprint.

"Peter T" wrote:

One second as a fraction of a day is
1/(24-60*60)
so for milliseconds divide by another 1000

Be aware though that accuracy to that degree will not be stored in a 'Date'
variable, also the Now function only returns the time to an accuracy one
second.

Depending on what you are doing, eg looking for some sort of timer, there
are different approaches.

Regards,
Peter T



"Gum" wrote in message
...
I have this:
Now() is current time.

Function myTime()
Dim t As Variant
t = Now() + TimeValue("00:00:20")
myTime= Format(t, "hh:mm:ss") & "." & Right(Format(Timer, "#0.00"), 2)
End Function

This adds 20 seconds to now()

I require to add milliseconds to Now() rather than seconds to get
mytime().
How can this be done?