Posted: 7/7/2011
In some cases my TaxTxtBox displays a number that has no remainder. When my TotPriceTxtBox has a value with no remainder it still displays to the 100th place "34.00". Then in TextBox1 it truncates the zeros. I need the TaxTxtBox and Textbox1 to diplay zeros to the 100th place when the is no remainder. I.E. keeping it in a money format. I tried using Decimal instead of double but I get an error saying that you cannot apply the *,+ operand to a Decimal or Doudle. Here's my code: protected void EnterBtn_Click(object sender, ImageClickEventArgs e) { Decimal res = Decimal.Parse(PriceTxtBox.Text); res = res * Decimal.Parse(QtyTxtBox.Text); TotPriceTxtBox.Text = res.ToString(); if (TotPriceTxtBox != null) { Double rs = Double.Parse(TotPriceTxtBox.Text); rs = (rs * (.070)) + Double.Parse(TotPriceTxtBox.Text); Double ts = (rs * (.070)); Double tt = ts + Double.Parse(TotPriceTxtBox.Text); Double output = Math.Round(rs, 2); Double output2 = Math.Round(ts, 2); Double output3 = Math.Round(tt, 2); TextBox1.Text = output3.ToString(); TaxTxtBox.Text = output2.ToString(); }
protected void EnterBtn_Click(object sender, ImageClickEventArgs e) { Decimal res = Decimal.Parse(PriceTxtBox.Text); res = res * Decimal.Parse(QtyTxtBox.Text); TotPriceTxtBox.Text = res.ToString(); if (TotPriceTxtBox != null) { Double rs = Double.Parse(TotPriceTxtBox.Text); rs = (rs * (.070)) + Double.Parse(TotPriceTxtBox.Text); Double ts = (rs * (.070)); Double tt = ts + Double.Parse(TotPriceTxtBox.Text); Double output = Math.Round(rs, 2); Double output2 = Math.Round(ts, 2); Double output3 = Math.Round(tt, 2); TextBox1.Text = output3.ToString(); TaxTxtBox.Text = output2.ToString(); }