Subtraction

Posted by: fhcnunes-fp on 8 September 2017, 12:46 pm EST

  • Posted 8 September 2017, 12:46 pm EST

    Hello,
    I am having a problem with subtraction formula. To illustrate my problem, I am sending two files. In the first file (Sheet1.jpg), you can see several values between C3 and C8 cells. In C9 cell, I put the sum formula to add those values. The expression is =SUM(C3:C8). In this case, the operation was executed correctly.

    In C10 cell, there is another value (563,28). As you can see in the next file (Sheet2.jpg), I subtracted the content of cell C10 by content of Cell9 (result of the sum operation) using the following expression: =C10-C9. The correct result of this operation is 563,28 - 565,29 = -2,01 and not -2,00999999999 as it was presented. Could you help me?
    Thanks a lot.

    2007/08/Sheets.rar
  • Replied 8 September 2017, 12:46 pm EST

    Hi,
    I am not using Excel. I am using a software developed by me using Farpoint component. I am using  FarPoint Spread for Windows Forms 3. Can you reproduce my problem?
    Thanks.
  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    I tested this with version 3.0.2004 and was not able to reproduce this issue. I changed the Regional Settings to a location that uses commas ',' as the decimal seperator and then typed the values and formulas into Spread and I get the correct result of -2,01. Make sure you are using the latest maintenance release. If you are, could you post a small zipped project reproducing this behavior for us to debug?

  • Replied 8 September 2017, 12:46 pm EST

    Hi,
    I am sending a small zipped project reproducing this behavior.
    I am also sending a XLS file.
    In this file, there is the example used to illustrate my problem.
    Thanks.

    2007/08/ErrorSubtraction.rar
  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    After assigning the formula, set the CellType property to NumberCellType to fix this issue.

     
          Me.FpSpread1.ActiveSheet.ActiveCell.Formula = Me.FpSpread1.ActiveSheet.ActiveCell.Text.Substring(1, Me.FpSpread1.ActiveSheet.ActiveCell.Text.Trim.Length - 1)
    Me.FpSpread1.ActiveSheet.ActiveCell.CellType = New FarPoint.Win.Spread.CellType.NumberCellType
     
  • Replied 8 September 2017, 12:46 pm EST

    Hello,


    What product are you using? It looks, from the pictures, that this is Excel.

  • Replied 8 September 2017, 12:46 pm EST

    It is working now.
    Thanks.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels