Get selected values in ListBox with multiple selectionmode property

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
 
H

Hero Ngan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top