Instead of namesListBox.Items.Count you can use
CODE
namesListBox.SelectedItems.Count
keep in mind though that selected indexes start a 0 so you will have to subtract 1 from the count.
so something like this should give you an acceptable result:
CODE
resultLabel.Text = String.Empty
For x As Integer = 0 To namesListBox.SelectedItems.Count - 1
resultLabel.Text &= namesListBox.SelectedItems(x).ToString & " "
Next
Which would also work in your singleButton.Click event... In other words, you only need a single button to handle whether a single selection is made or a multiple selection.
On more tip; in your SingleButton.Click you can achieve the same results just by simply using
CODE
resultLabel.text = Convert.ToString(namesListBox.SelectedItem)
But as I stated above, you can achieve both results with the other example.
This post has been edited by CharlieMay: 6 Nov, 2009 - 02:29 AM