[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

FileListBox or ListBox - Multiselect Problem

Posted on 2004-09-29
2
Medium Priority
?
736 Views
Last Modified: 2013-12-26
One of the components of my GUI project is that I currently have a FileListBox that I need the user to be able to select multiple files from. I have the code in place to examine an array populated with the FileListBox contents and another array gets created of only the files that are selected. I have this functionality working fine, when the files are selected from top to bottom within the filelistbox contents, in other words in the same numerical order as the indexing. But If file selections are made in any other order, (bottom to top, or random) only the last file (or files selected, that coincide with indexing) get selected and thus get enumerated in the second array.

Is there a way to get the selected files from the FileListBox regardless of what order they are selected?

       
0
Comment
Question by:boris711
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 12184148
How about this approach?

Option Explicit

' holds the names of the selected files
Private selectedFiles As Collection

Private Sub Form_Load()
    File1.Path = "c:\"
End Sub

' building the collection of selected files...
Private Sub Command1_Click()
    Dim i As Integer
   
    Set selectedFiles = New Collection
    For i = 0 To File1.ListCount - 1
        If File1.Selected(i) Then
            selectedFiles.Add File1.List(i)
        End If
    Next i  
End Sub

' enumerating the collection of selected files...
Private Sub Command2_Click()
    Dim curFile As Variant
   
    If Not (selectedFiles Is Nothing) Then
        For Each curFile In selectedFiles
            Debug.Print curFile
        Next
    End If
End Sub
0
 
LVL 1

Author Comment

by:boris711
ID: 12184586
That worked perfect!

I am relativly new to programming, and hadn't thought of using a collection vs. an array.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question