Sam Phillips

Sam Phillips

  • NA
  • 11
  • 1.3k

Calculating percentage of left over cost displaying result a

Jun 7 2019 8:31 AM
  1. double number;  
  2. double number1;  
  3. double result;  
  4.   
  5. double.TryParse(SelectedQuoteForEditing.JobPrice, out number);  double.TryParse(lblRate.Content.ToString().ToString(), out number1);  
  6.   
  7. var left = Math.Round((number - number1) / number * 100, 2);  
  8.   
  9. result = left;  
  10.   
  11. ERGPerc.Content = result.ToString("P") + "%";  
I am trying to show the percentage which is left after number1 has subtracted from number. The values I am calling contain a £ symbol and when running the code I get the result of "NaN" I guess this is to do with the £ sign as when removed code works. Anyone have any idea how I can fix this please ? I have been trying for hours with no luck :( Thanks in advance.

Answers (3)