
Problem with Conditional Formating
That's a normal result of the inherent imprecision of
floating point numbers Brian.
Try adding a half second (approx. 6E-6) to interval to help
deal with the "rounding error".
LngHours = Int((interval + 6E-6) * 24)
LngMinutes = Int((interval + 6E-6) * 1440) Mod 60
Marsh
On Thu, 4 Apr 2002 22:53:24 -0800, "Brian"
Quote:
>Hello. I am using the VB code detailed below to calculate
>and display an elapsed time in a form. I am having
>difficulty getting a conditional format to work when the
>resulting value is greater than 14 hours and 00 minutes.
>Doesn't 14 hrs. 00 min. = 0.583333333328483?
>? CDbl (#12/14/2002 14:01:00#-#12/14/2002 00:01:00#)
> 0.583333333328483
>Maybe I am doing something wrong here. Any ideas?
>Thanks,
>Brian
>Function GetElapsedTime(interval)
> Dim LngHours As Long, LngMinutes As Long
> If IsNull(interval) Then
> GetElapsedTime = 0
> Else
> LngHours = Int(interval * 24)
> LngMinutes = Int(interval * 1440) Mod 60
> GetElapsedTime = LngHours & " Hours " & LngMinutes
>& " Minutes"
> End If
>End Function
Marsh