I'm really having a hard time with this. This code is suppose to be solving a total payment and put it into the sub total TextBox
, but when i try to convert it to double
(because the prices have decimals
), this is what it came up with. I've tried int
and it didnt have any problems.
Any solutions for this?
double i = 0;
double j = 0;
double k = 0;
i = 0;
j = 0;
k = 0;
try
{
j = lstvProds.Items.Count;
for (i = 0; i <= j - 1; i++)
{
k = k + Convert.ToDouble(lstvProds.Items[i].SubItems[4].Text);
}
//double l = Convert.ToDouble(k);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return k;