Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# - Bug
Message
De
27/09/2005 04:46:59
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
01053289
Message ID:
01053322
Vues:
13
>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");
>       }
>     }
>  }
>
Cecil,
Textbox doesn't have an InputMask propperty so I assume you use a subclassed textbox. Probably your subclass is already doing a conversion and rendering decimal.Parse useless.
Try with base textbox controls. It works as expected.

Update: Might it be you have currency in your text ($)?

decSubTotal = decimal.Parse (this.basePriceMaskedTextBox.Text,
System.Globalization.NumberStyles.Currency);

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform