Click to See Complete Forum and Search --> : FileListBox


quadland
May 18th, 2001, 09:44 AM
I have setup a filelistbox that allows multiple selections. How do I view each selection in the code (i.e. File1.FileName just shows me the last selection, I want all selected items. File1.Selected (#) just tells me if that number was selected.) I assume I could write a for loop that checks if each item was selected and stick the results in an array, but I figure there has to be an easier way.

Thanks,
Quad

shree
May 18th, 2001, 10:35 AM
Isn't that easy enough? :)

quadland
May 18th, 2001, 10:38 AM
If that is the only option, but I hate to do excess processing when it could be a property array of the component.

Cimperiali
May 18th, 2001, 10:51 AM
From msdn:

Private Sub Form_Load ()
Dim I ' Declare variable.
' Fill the list box with screen font names.
For I = 0 To Screen.FontCount - 1
List1.AddItem Screen.Fonts(I)
Next I
End Sub

Private Sub Command1_Click ()
Dim I ' Declare variable.
' Clear all items from the list.
List2.Clear
' If an item is selected, add it to List2.
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
List2.AddItem List1.List(I)
End If
Next I
End Sub



Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

coolbiz
May 18th, 2001, 11:57 AM
Nope, that is the easiest way and the only way :)

-Cool Bizs