MatchEntry Property

Applies To

ComboBox control, ListBox control.

Description

Returns or sets a value indicating how a ListBox or ComboBox searches its list as the user types.

Syntax

object.MatchEntry [= fmMatchEntry]

The MatchEntry property syntax has these parts:

Part

Description

object

Required. A valid object.

fmMatchEntry

Optional. The rule used to match entries in the list.


Settings

The settings for fmMatchEntry are:

Constant

Value

Description

fmMatchEntryFirstLetter

0

Basic matching. The control searches for the next entry that starts with the character entered. Repeatedly typing the same letter cycles through all entries beginning with that letter.

FmMatchEntryComplete

1

Extended matching. As each character is typed, the control searches for an entry matching all characters entered (default).

FmMatchEntryNone

2

No matching.


Remarks

The MatchEntry property searches entries from the TextColumn property of a ListBox or ComboBox.

The control searches the column identified by TextColumn for an entry that matches the user's typed entry. Upon finding a match, the row containing the match is selected, the contents of the column are displayed, and the contents of its BoundColumn property become the value of the control. If the match is unambiguous, finding the match initiates the Click event.

The control initiates the Click event as soon as the user types a sequence of characters that match exactly one entry in the list. As the user types, the entry is compared with the current row in the list and with the next row in the list. When the entry matches only the current row, the match is unambiguous.

In Microsoft Forms, this is true regardless of whether the list is sorted. This means the control finds the first occurrence that matches the entry, based on the order of items in the list. For example, entering either "abc" or "bc" will initiate the Click event for the following list:

abcde
bcdef
abcxyz
bchij
Note that in either case, the matched entry is not unique; however, it is sufficiently different from the adjacent entry that the control interprets the match as unambiguous and initiates the Click event.

See Also

BoundColumn property, Click event, MatchFound property, MatchRequired property, TextColumn property.

Example

The following example uses the MatchEntry property to demonstrate character matching that is available for ComboBox and ListBox. In this example, the user can set the type of matching with the OptionButton controls and then type into the ComboBox to specify an item from its list.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • Three OptionButton controls named OptionButton1 through OptionButton3.
  • A ComboBox named ComboBox1.
    Private Sub OptionButton1_Click()
        ComboBox1.MatchEntry = fmMatchEntryNone
    End Sub
    
    Private Sub OptionButton2_Click()
        ComboBox1.MatchEntry = fmMatchEntryFirstLetter
    End Sub
    
    Private Sub OptionButton3_Click()
            ComboBox1.MatchEntry = fmMatchEntryComplete
    End Sub
    
    Private Sub UserForm_Initialize()
        Dim i As Integer
        
        For i = 1 To 9
            ComboBox1.AddItem "Choice " & i
        Next i
        ComboBox1.AddItem "Chocoholic"
        
        
        OptionButton1.Caption = "No matching"
        OptionButton1.Value = True
        
        OptionButton2.Caption = "Basic matching"
        OptionButton3.Caption = "Extended matching"
    End Sub