how to display the listbox items to a label using VB2008
- by Cecilia
I am trying to display listbox items in a label.
After debugging,I get the error : " make sure that the maximun index on the list is less than the list size"
any comment will be highly appreciate,
Private Sub xMultiButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles xMultiButton.Click
Dim count As Integer
count = Me.xNamesListBox.Items.Count
For count = 0 To 3
Me.xResultLabel.Text = Me.xNamesListBox.SelectedItems.Item(0).ToString & ControlChars.NewLine _
& Me.xNamesListBox.SelectedItems.Item(1).ToString & ControlChars.NewLine _
& Me.xNamesListBox.SelectedItems.Item(2).ToString & ControlChars.NewLine _
& Me.xNamesListBox.SelectedItems.Item(3).ToString & ControlChars.NewLine _
& Me.xNamesListBox.SelectedItems.Item(4).ToString
Next
End Sub