Try storing results or using double.

Sub test()
    Dim d As Double
    Dim s As Single

    d = 0.004
    Debug.Print "d", d, d + 0.1
    s = 0.004
    Debug.Print "s", s, s + 0.1
    d = d + 0.1
    Debug.Print "d + 0 .1", d
    s = s + 0.1
    Debug.Print "s + 0.1", s
End Sub

Immediate Window:
d              0.004         0.104
s              0.004         0.10400000018999
d + 0 .1       0.104
s + 0.1        0.104



On Apr 7, 9:45 am, mike <mikesal...@gmail.com> wrote:
> I'm working with variables that hold three decimal point numbers such
> as .001 and 3.185.  Excel VBA seems to add extra digits to these
> variables so that instead of -0.004 the value is -0.00400000018998981
> for example.
>
> I've tried adding lots of rounding statements everytime I work with
> the variables where I round to three decimals places.  The code is
> becoming ugly looking adding these rounding statements.  Is there
> another way to control the digits after decimal?

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

To unsubscribe, reply using "remove me" as the subject.

Reply via email to