Results 1 to 2 of 2

Thread: File list

  1. #1

    Thread Starter
    Lively Member adifel's Avatar
    Join Date
    Jan 2006
    Location
    California
    Posts
    103

    File list

    I'm gathering the selected files from a folder into a ListBox, everything is fine as long as I select the files by mouse, but if I use shift+mouse to select multiple rows of files, the last one goes first on the list. Any idea how to correct this would be appreciated.

    Code:
    Private Sub cmdBrowse_Click()
      Dim sArr() As String
      Dim i As Long
      comBrowse.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
      comBrowse.ShowOpen
      sArr = Split(comBrowse.Filename, Chr(0))
      For i = 0 To UBound(sArr())
        lstFiles.AddItem sArr(i)
        lstPath.AddItem lstFiles.List(0) & "\" & sArr(i)
      Next i
      lstFiles.RemoveItem 0
      lstPath.RemoveItem 0
     End Sub 'cmdBrowse_Click()
    There are 2 ListBoxes, one with just filenames (lstFiles) the other with path+file names (lstPath).

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: File list

    try
    vb Code:
    1. For i = 0 To UBound(sArr())
    2.     lstFiles.AddItem sArr(i)
    3.     lstPath.AddItem lstFiles.List(i) & "\" & sArr(i)
    4.   Next i
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width