• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

error in VB6 with filelistbox

I use as follows
 With filvrije
   .Path = "J:\labels\"
   .Pattern = "*.xls"
 End With

But this will also show xlsx files
  • 2
  • 2
1 Solution
What happens if you put a space between the last S and the quotes. like "*.xls "?
BIAPROAuthor Commented:
still shows
I think you will need to copy the files to regular listbox then and screen them yourself. Something like...

Option Explicit

Private Sub Command1_Click()
  Call FillFileList("C:\")
End Sub

Private Sub FillFileList(byval sFolder as string)
   Dim sFilename as string
   list1.clear  '<--- added this in case you call the sub more than once.
   if Right (sFolder,1) <> "\" then sFolder = sFolder & "\"
   sFilename = Dir$(sFolder & *.xls")
   do until sFilename = ""
      if Right(sFilename,4) <> "xlsx" then
      	list1.additem clipExt(sFilename)
      End If
      sFilename = Dir$
End Sub

Private Function ClipExt(byval fname as string) as string
  Dim nPos as string
  nPos = InStrRev(fname,".")
  if nPos > 0 then
    fname = mid(fname,1,nPos-1)
  end if
  ClipExt = fname
End function

Open in new window

BIAPROAuthor Commented:
thanks, that will do
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now