Steuerelementzeichenabgleich in einem Kombinationsfeld und Listenfeld

The following example uses the MatchEntry property to demonstrate character matching that is available for ComboBox and ListBox. In diesem Beispiel kann der Benutzer den Typ des Abgleichs mit den OptionButton-Steuerelementen festlegen und dann in das ComboBox-Steuerelement eingeben, um ein Element aus seiner Liste anzugeben.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Drei Optionsfeld-Steuerelemente ( OptionButton ) mit der Bezeichnung "OptionButton1" bis "OptionButton3".

  • A ComboBox named ComboBox1.

Sub OptionButton1_Click() 
 Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1") 
 ComboBox1.MatchEntry = 2 '2=fmMatchEntryNone 
End Sub 
 
Sub OptionButton2_Click() 
 Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1") 
 ComboBox1.MatchEntry = 0 '0=fmMatchEntryFirstLetter 
End Sub 
 
Sub OptionButton3_Click() 
 Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1") 
 ComboBox1.MatchEntry = 1 '1=fmMatchEntryComplete 
End Sub 
 
Sub Item_Open() 
 Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1") 
 Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1") 
 Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2") 
 Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3") 
 
 For i = 1 To 9 
 ComboBox1.AddItem "Choice " & i 
 Next 
 ComboBox1.AddItem "Chocoholic" 
 
 OptionButton1.Caption = "No matching" 
 OptionButton1.Value = True 
 
 OptionButton2.Caption = "Basic matching" 
 OptionButton3.Caption = "Extended matching" 
End Sub

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.