Get selected values in ListBox with multiple selectionmode property

  • Thread starter Thread starter Matthew Louden
  • Start date Start date
M

Matthew Louden

I created a listbox with multiple selectionmode property, but I have trouble
to get a list of selected values.

The following only gets the first selected value, not others.

TextBox2.Text = ListBox1.SelectedValue

Please help!!
Thanks
 
I think you can use a For-Loop to loop the listbox, then check the item is
selected or not.

Roughly code:

' loop the ListBox items
For iLoop = 0 To ListBox1.Items.Count - 1
' item selected
If ListBox1.Items(iLoop).Selected Then
TextBox2.Text = TextBox2.Text & ListBox1.Items(iLoop).Value & ";"
End If
Next

Hope can help you!

Rdgs,
Hero Ngan
 
Back
Top