By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,963 Members | 1,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,963 IT Pros & Developers. It's quick & easy.

Tenths and hundreths of second

P: n/a
Hi there:

with these instructions

....
dim c, d as Double
c=cdbl(now)
....
d=cdbl(now)
? (d-c)*86400
....

I get values like these:
1,00000023376197
1,99999983888119
0
0
1,00000023376197
4,00000030640513

or even with interactive tests like:

b=now
a=now
? a
03/03/2006 13:19:17
? b
03/03/2006 13:19:13
? cdbl((a-b) * 60 * 60 * 24)
3,99999967776239
i.e., I always get values with no decimal part (that is, like 1 second,
2 seconds, 0, 0, 1, 4...)

I've been trying to find help at the news... with no positive result
:-(

what I intend to do is the usual chrono form, in which every time I
strike a key, I'll save in a field the timing difference between the
1st and the 2nd key stroke, and, the important thing:

show the info in format of seconds.tenths hundreths, like 15.35

Will be waiting for your help, thanks in advance

Mar 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 3 Mar 2006 05:03:37 -0800, jv*********@hotmail.com wrote:

In these situations I always use the GetTickCount API which gives
milliseconds (though not necessarily millisecond accuracy). I would
store it in a form-level global variable:
private m_lngTickCount as Long

private sub txtTest_KeyDown()
if m_lngTickCount = 0 then
m_lngTickCount = GetTickCount()
else
debug.print "Time diff = " & GetTickCount() - m_lngTickCount & "
msec"
m_lngTickCount = GetTickCount()
end if
end sub

In a module you need to declare:
Public Declare Function GetTickCount Lib "kernel32" Alias
"GetTickCount" () As Long

-Tom.

Hi there:

with these instructions

...
dim c, d as Double
c=cdbl(now)
...
d=cdbl(now)
? (d-c)*86400
...

I get values like these:
1,00000023376197
1,99999983888119
0
0
1,00000023376197
4,00000030640513

or even with interactive tests like:

b=now
a=now
? a
03/03/2006 13:19:17
? b
03/03/2006 13:19:13
? cdbl((a-b) * 60 * 60 * 24)
3,99999967776239
i.e., I always get values with no decimal part (that is, like 1 second,
2 seconds, 0, 0, 1, 4...)

I've been trying to find help at the news... with no positive result
:-(

what I intend to do is the usual chrono form, in which every time I
strike a key, I'll save in a field the timing difference between the
1st and the 2nd key stroke, and, the important thing:

show the info in format of seconds.tenths hundreths, like 15.35

Will be waiting for your help, thanks in advance


Mar 3 '06 #2

P: n/a
Worked perfectly !

Thanks very much, Tom ;-)

Mar 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.