VB timer as Double

Posted on Friday 17 February 2006

Ok so this is a lazy post, but has anyone used the timer with double type?
Try it, I'm looking into this and hope to get a better understanding of the whole thing, but it seems to use 3 decimal places when loading the time, and more when subtacting (more sdp than singles). In documention it says Timer returns a single. Thus i would have thought (FLW!) that if the result was getting put in a double it would return the same result, and maybe add some zeros. But if that's the limit of the timer then the other numbers shouldn't be there - right?

Sub TimerTest()

Dim LongTimer  As Long
Dim VariantTimer As Variant
Dim DoubleTimer As Double
Dim IntegerTimer As Integer
Dim SingleTimer As Single
Dim x As Long

LongTimer = Timer
VariantTimer = Timer
SingleTimer = Timer
DoubleTimer = Timer

MsgBox "Long " & LongTimer & vbNewLine _
& "Sng " & SingleTimer & "
& "
Var " & VariantTimer & "
& "Doub " & DoubleTimer & "
Title:="
  Timer Things                                              "

Do Until x = 100
'waste some time
x = x + 1
Loop

LongTimer = Timer - LongTimer
SingleTimer = Timer - SingleTimer
VariantTimer = Timer - VariantTimer
DoubleTimer = CDbl(Timer) - DoubleTimer

MsgBox "Long " & LongTimer & vbNewLine _
& "
Sng " & SingleTimer & vbNewLine _
& "
Var " & VariantTimer & vbNewLine _
& "
Doub " & DoubleTimer & vbNewLine, _
Title:="
  Timer Things"

End Sub

Run this a few times - some times the reults are "perfect" subtractions". I dont really understand what's going on here, i dont think the double stores at a higher "resolution". Also the cdbl(timer) is a bit unfair....
Any ideas/thoughts


No comments have been added to this post yet.

Leave a comment

(required)

(required)


.

Use [VBA] Your Code [/VBA], when posting code, cheers Ross x /


RSS feed for comments on this post | TrackBack URI