Help outputting multiple Listbox items to a label (VB)

GenDV138

Newcomer
Joined
Apr 10, 2003
Messages
2
Location
VA
Help outputting multiple Listbox items to a label

I am having trouble with my VB.NET listbox program. My listbox has five names and its SelectionMode is set to MultiExtended. There is also a label, Single Selection Button, Multi-Selection Button, and an Exit Button.

My first button, Single Selection, will output a single selected item in the listbox into the label. I didn't have trouble with the code for this button.

The second button, Multi-Selection, should output multiple selected items in the listbox to the label, each item on a seperate line in the label. I'm stumped on this part and cannot figure out what to do. Any help would be greatly appreciated. Thanks!
 
Use the SelectedItems collection:
Visual Basic:
Dim si As String

For Each si In ListBox1.SelectedItems
     Label1.Text &= si & ControlChars.CrLf
Next
 
Back
Top