how to display the listbox items to a label using VB2008

Posted by Cecilia on Stack Overflow See other posts from Stack Overflow or by Cecilia
Published on 2011-01-11T04:16:15Z Indexed on 2011/01/11 4:53 UTC
Read the original article Hit count: 174

Filed under:

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

© Stack Overflow or respective owner

Related posts about vb