Gaetano D

Gaetano D

  • NA
  • 21
  • 54.3k

Stupid problem

Dec 2 2010 4:15 PM

 I have 3 text boxes that do a simple math equation, but I must be messing up my format. All Im doing is dividing the downpayment by the sales price. Then it should display the percentage of down payment in the downPaymentPercentTextBox. It works fine at first but when I clear out downPaymentTextbox I get this error:
ERROR MESSAGE WHEN DEBUGGING:  Input string was not in a correct format.
Here is the code... Please tell me what Im doing wrong.. The method starts when I put a number in the downPaymentTextBox and the error happens when I manually delete the input from the same box... Im lost
private
void downPaymentTextBox_TextChanged(object sender, EventArgs e)
{
decimal Price = Convert.ToDecimal(salesPriceTextBox.Text);
decimal DownPay = Convert.ToDecimal(downPaymentTextBox.Text);
decimal Percent = (DownPay / Price) * 100;
downPaymentPercentTextBox.Text =
Convert.ToString(Percent);
}

 
ERROR MESSAGE WHEN DEBUGGING:  Input string was not in a correct format.

Answers (10)