G
Gary Keramidas
i use the first code snippet to populate a userform listbox as the user types in
a filename into a
textbox. so, it a user starts to type "test", it will filter the filenames that
start with "test".
so i tried the 2nd code snippet, but it is very slow to react to the textbox
input
is there another way that would perform better as the user types "test" into a
textbox,
so the listbox is populated with "testing.xls" and "this is a test.xls"?
Me.ListBox1.Clear
fname = Dir(fPath & "\" & Me.tbCode & "*.xls")
Do While fname <> ""
Me.ListBox1.AddItem StrConv(Left(fname, Len(fname) - 4),
vbProperCase)
fname = Dir()
Loop
'2nd code
Set fs = Application.FileSearch
With fs
.LookIn = fPath
.SearchSubFolders = False
.Filename = "*" & Me.tbCode & "*.xls"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Me.ListBox1.AddItem Right(.FoundFiles(i),
Len(.FoundFiles(i)) - InStrRev(.FoundFiles(i), "\"))
Next i
Else
End If
End With
a filename into a
textbox. so, it a user starts to type "test", it will filter the filenames that
start with "test".
so i tried the 2nd code snippet, but it is very slow to react to the textbox
input
is there another way that would perform better as the user types "test" into a
textbox,
so the listbox is populated with "testing.xls" and "this is a test.xls"?
Me.ListBox1.Clear
fname = Dir(fPath & "\" & Me.tbCode & "*.xls")
Do While fname <> ""
Me.ListBox1.AddItem StrConv(Left(fname, Len(fname) - 4),
vbProperCase)
fname = Dir()
Loop
'2nd code
Set fs = Application.FileSearch
With fs
.LookIn = fPath
.SearchSubFolders = False
.Filename = "*" & Me.tbCode & "*.xls"
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Me.ListBox1.AddItem Right(.FoundFiles(i),
Len(.FoundFiles(i)) - InStrRev(.FoundFiles(i), "\"))
Next i
Else
End If
End With