getting selected listbox values

X

x taol

i set multiselect property of listbox control to fmMultiSelectExtended.
by the way, i want to get the selected list names.
the following code...??

for i = 0 to listbox1.listcount - 1
if listbox1.list(listbox1.listindex).selected then
msgbox listbox1.list(listbox1.listindex)
endif
next
 
N

Norman Jones

Hi X Taol,

Try:

'=============>>
Private Sub CommandButton1_Click()
Dim i As Long

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
MsgBox ListBox1.List(i)
End If
Next i

End Sub
'<<=============
 

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