Visual Web Developer 2010
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:
Code:01 protected void EnterBtn_Click(object sender, ImageClickEventArgs e) 02 { 03 Decimal res = Decimal.Parse(PriceTxtBox.Text); 04 res = res * Decimal.Parse(QtyTxtBox.Text); 05 TotPriceTxtBox.Text = res.ToString(); 06 07 if (TotPriceTxtBox != null) 08 { 09 Double rs = Double.Parse(TotPriceTxtBox.Text); 10 rs = (rs * (.070)) + Double.Parse(TotPriceTxtBox.Text); 11 12 Double ts = (rs * (.070)); 13 Double tt = ts + Double.Parse(TotPriceTxtBox.Text); 14 Double output = Math.Round(rs, 2); 15 Double output2 = Math.Round(ts, 2); 16 Double output3 = Math.Round(tt, 2); 17 18 TextBox1.Text = output3.ToString(); 19 TaxTxtBox.Text = output2.ToString(); 20 }




Reply With Quote