VBA matching entries in Listbox

R

revduke123

HI all,

I'm using Office 2004, and trying to use a listbox to enable user to
choose an item - in this case, a filename from a list of filenames.
The code is below.
The form opens up fine, the list of files appears fine, you can use
the up/down arrows to select items; but I can't get the 'matching'
feature to work. As soon as you press any other key, the selection
jumps to the top of list. I want the selection to jump to the first
occurrence of the phrase tha the user types in, using the 'complete
match' process

Any ideas what I'm doing wrong?
Thanks for any help.
Revduke

Sub testuserform()

dirlist ' this sub sticks a directory listing into a string array
called file_names
BubbleSort (file_names) 'now I sort it
Load UserForm1
UserForm1.ListBox1.MatchEntry = fmMatchEntryComplete
UserForm1.ListBox1.ColumnCount = 1
UserForm1.ListBox1.List() = file_names
UserForm1.ListBox1.TextColumn = 1
UserForm1.Show
End Sub
 
S

Steve Rindsberg

Did you try typing the first couple characters of the entry very quickly.
I'm testing this on a PC at the moment, so you may be seeing something
different, but here if I have entries like

abc
def
abd

when I type "abd" very quickly, it works.
If I type ab then d, first abc is highlighted then def (it sees ab then after a
pause, d)

Revduke123 said:
HI all,

I'm using Office 2004, and trying to use a listbox to enable user to
choose an item - in this case, a filename from a list of filenames.
The code is below.
The form opens up fine, the list of files appears fine, you can use
the up/down arrows to select items; but I can't get the 'matching'
feature to work. As soon as you press any other key, the selection
jumps to the top of list. I want the selection to jump to the first
occurrence of the phrase tha the user types in, using the 'complete
match' process

Any ideas what I'm doing wrong?
Thanks for any help.
Revduke

Sub testuserform()

dirlist ' this sub sticks a directory listing into a string array
called file_names
BubbleSort (file_names) 'now I sort it
Load UserForm1
UserForm1.ListBox1.MatchEntry = fmMatchEntryComplete
UserForm1.ListBox1.ColumnCount = 1
UserForm1.ListBox1.List() = file_names
UserForm1.ListBox1.TextColumn = 1
UserForm1.Show
End Sub

================================================
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top