Ok, if the code is correct, why did it not work?
Yes, I read the text about the "Listbox must contain integers ... ".
Your earlier post said that one way to load numbers is to use :
Code:
myListBox.Items.Add(1337);
which, in this case, would be :
Code:
valuesListBox.Items.Add(1337);
but where does it say that in the example in the book?
If the book had included that line, then the code would have worked.
But where would one put that line??
As the code includes a check to make sure the listbox is not empty, one could not include that line before the check, or that would negate the check.
If one adds it after the check, then the code stops at the messagebox.
That is why I assumed the numbers must be entered by the user, not by the code.
But how does the user enter numbers into a ListBox? Would not a textbox be required?
So I entered numbers(strings) via the listbox Properties, but couldn't remember how to convert them to integers.
Parse was the solution.