Decimal Problem

I have a problem on decimal value.
e.g;
   a = 1.234
   b = 2.345
   c = a - b
 
 ans c should -1.111, but sometime the ans for c will be -1.111999999999.  And again, if i want ans in 3 decimal places only.


Pls reply me. Thank you

KelvsatAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mcriderConnect With a Mentor Commented:
Try using the Format function... For example:


    Dim a As Double
    Dim b As Double
    Dim c As Double
    a = 1.234
    b = 2.345
    c = CDbl(Format(a - b, "0.000"))


Cheers!
0
 
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
All Courses

From novice to tech pro — start learning today.