// Calculating and diplaying pricing in list.
for (double MAX = 4.25; MAX >= MIN; MAX -= 0.05)
{
Price = (X * MAX);
prices = Price.ToString("c");
listFinances.Items.Add(prices);
}
---
private void listFinances_SelectedIndexChanged(object sender, EventArgs e)
{
string TotalPrice = listFinances.SelectedItem.ToString();
double stateIncentive = (Convert.ToDouble(TotalPrice) / 4);
txtStateTax.Text = stateIncentive.ToString();
}
So I'm trying to take a ListBox
of string currency values, turn them into a double, divide them by 4, and display the result in a TextBox
. The user will select the ListBox
value and the program should automatically divide by 4 and display.
It's not working however. The program always does an exception throw when you click the ListBox
item. The exception is thrown at:
double stateIncentive = (Convert.ToDouble(TPrice) / 4);
saying that:
It's not in the correct format.
Can someone help me out here?