Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
populate listbox as textbox changes question
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 -- Gary |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
populate listbox as textbox changes question
forget it, i changed this line and it seems to be working.
fname = Dir(fPath & "\*" & Me.tbCode & "*.xls") -- Gary "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... 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 -- Gary |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Populate a ListBox | Excel Programming | |||
populate listbox? | Excel Programming | |||
populate listbox | Excel Programming | |||
Populate listBox | Excel Programming | |||
ListBox Populate | Excel Programming |