Basically the first for statement below creates a list of testvalue labels depending on the user input.
The second for statement is supposed to work out the total of the dynamic labels created but when i play it i get an error saying “Input string was not in a correct format.” relating to tots += double.Parse(value[p].ToString()); Any help would be appreciated. Thanks
ArrayList value = new ArrayList();
int p =0;
for (int i = 0; i < weight.Count; i++)
{
Label test = new Label();
System.Drawing.Point l8 = new System.Drawing.Point(440, 48 + s);
test.Location = l8;
value.Add(test);
k += 35;
Label l2 = testpercent1[i] as Label;
Double.TryParse(l2.Text.Trim(), out label2);
Label l = testpercent2[i] as Label;
Double.TryParse(l.Text.Trim(), out label1);
Double testvalue = Math.Round(((label1 * .3) + (label2 * .4)));
test.Text = testvalue.ToString();
}
Double total = 0;
for (int p = 0; p < value.Count; p++)
{
tots += double.Parse(value[p].ToString());
}
1 Answer