LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Test for fractions of a penny

I'm attempting to write code to determine if the user entered a value
that has a fraction of a cent. Here is my logic

dim i as long
dim d as double

If IsNumeric(.Value) = True And .Value < 0 Then
.Value = Abs(.Value)
i = CLng(CDbl(.Value) * 100)
d = CDbl(.Value) * 100
If Abs(d - i) 0 Then
MsgBox "Rounding error detected! Make sure you don't have umbers
with values less than 1/100th", vbExclamation
End If
Else
.Value = ""
End If

It seems to work for most cases however I'd found some specific values
that always report "Round error detected!...."

Values such as 282.47, 32.41 and 132.70

If I MsgBox i & " " & d the numbers are the same so
Abs(d - i) 0 should always be false I don't quite understand what's
doing on. Is there a better way to test for fractions of a cent?

Eric

 
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
Calc sometimes off by a penny Access Joe Excel Worksheet Functions 6 April 29th 23 03:43 AM
Exel 2007 penny off scarter Excel Discussion (Misc queries) 4 April 10th 08 01:43 AM
AutoSum lost a penny PoldenKaz Excel Worksheet Functions 5 September 28th 07 01:30 PM
My accounting program is a penny off, Why? bigelwood Excel Worksheet Functions 2 April 23rd 07 01:46 AM
In Excel the total is off by a penny. jules Excel Worksheet Functions 1 June 17th 05 03:43 AM


All times are GMT +1. The time now is 07:49 AM.

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"