Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a ListBox JB in Kansas Excel Programming 6 September 19th 05 03:01 PM
populate listbox? Alen32 Excel Programming 2 June 4th 05 01:18 PM
populate listbox JSnader Excel Programming 2 December 6th 03 02:43 PM
Populate listBox Hamster Excel Programming 1 September 17th 03 01:14 PM
ListBox Populate Rod Taylor Excel Programming 3 July 22nd 03 12:11 AM


All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"