Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# - Bug
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
C# - Bug
Miscellaneous
Thread ID:
01053289
Message ID:
01053289
Views:
43
I am in a C# class and am having a problem with the Masked TextBox. I must not understand something. The two masked TextBoxes are for the Base Price and the SubTotal. They have the input mask of 999,999.99 foir the base price and 99,999.99 for the SubTotal. I get an error, but it's not even a complete error; it says, "Input string not in correct format." See the lines marked with the double asterisks below (**).
//The following line is put ahead of all the below code:
 private decimal decSubTotal = 0M;

 private void calculateButton_Click(object sender, EventArgs e)
 {
   string strMessageString;
   //Calculate the cost of the vehicle.
   if (this.basePriceMaskedTextBox.Text != "")
     {
     //Convert from Text to Decimal value.
   **  decSubTotal = decimal.Parse(this.basePriceMaskedTextBox.Text);
     if (this.tradeInAllowanceMaskedTextBox.Text != "")
       {
       decTradeInAllowance = 
        ** decimal.Parse(this.tradeInAllowanceMaskedTextBox.Text);
         decSubTotal += decTradeInAllowance;
         this.subTotalLabel.Text = decSubTotal.ToString("C");
       }
     }
  }
Next
Reply
Map
View

Click here to load this message in the networking platform