Option Explicit
Private Sub CB_KeyUp(KeyCode As Integer, Shift As Integer) Static NoSelectText As String Dim i As Long Const RGBerror = 255 With CB If KeyCode = vbKeyUp Then Exit Sub If KeyCode = vbKeyDown Then Exit Sub If KeyCode = vbKeyLeft Then Exit Sub If KeyCode = vbKeyRight Then Exit Sub If KeyCode <> vbKeyBack Then NoSelectText = Mid(.Text, 1, Len(.Text) - .SelLength) Else If NoSelectText <> "" Then NoSelectText = Mid(NoSelectText, 1, Len(NoSelectText) - 1) End If End If For i = 0 To .ListCount - 1 If UCase(NoSelectText) = UCase(Mid(.List(i), 1, Len(NoSelectText))) Then .ListIndex = i Exit For End If Next .SelStart = Len(NoSelectText) .SelLength = Len(.Text) If .ListIndex = -1 Then .BackColor = RGBerror Else .BackColor = vbWindowBackground End If End With End Sub Private Sub Form_Load() With CB .AddItem "Marco" .AddItem "Federico" .AddItem "Francesco" .AddItem "Francis" .AddItem "Virginia" .AddItem "Valeria" .AddItem "Viviana" End With End Sub |