Abhinav is right...which is why I marked his answer as a 5, but I wanted to elaborate a bit more on what he said and provide (hopefully) some helpful tips for the future.
When you get an error like this, the best thing to do is go through your code step by step in the debugger. If you are using Visual Studio, use your Watch window. If something doesn't work the way you expected, put each of the variables into the watch window and see the results.
In your case, if you had done this, you could have started by putting
listBox1.SelectedItems.ToString()
in the watch window. If you had done that, you would have seen that it equaled something like:
System.Windows.Forms.ListBox+SelectedObjectCollection
That's probably not what you were expecting. Then, when you used the
Parse
function, it would have thrown an error because it is not a numeric value.
My other suggestion is only use the
Parse
methods if you are assured that it will work. Otherwise, use
TryParse
instead.