TextBox[] TextBoxList = new TextBox[] { txtChipPrice, txtDrinkPrice, txtBurgerPrice, txtFishPrice, txtPriceOther, txtTubPrice, txtChickenPrice };
double total = 0;
foreach (TextBox txt in TextBoxList)
{
total += Convert.ToDouble(txt.SelectedText);
}
txtTotalPrice.Text = total.ToString();
What I'm doing is I'm adding together a collection of product prices in different Textboxes into 1 textbox to get the total price.
I keep getting an error message saying I can't change a string to a double.
"Input string was not in a correct format."
The line of code with the problem is :
total += Convert.ToDouble(txt.SelectedText);
Can anybody help me?

New Topic/Question
Reply




MultiQuote








|