ComboBox Speed Fill

The following code performs a speed fill on your comboBox.  To use it call it from your combobox KeyUp Event, but do not process the backspace or arrow keys etc.  eg:

Select Case KeyCode
    Case 32, &H30 To &H6F, Is > &H7F
        ComboBoxSpeedFill Combo1
End Select


Add the following code to your form or in a module 

Private Declare Function SendMessage _
      Lib "user32" Alias "SendMessageA" _
      (ByVal hwnd As Long, ByVal wMsg As Long, _
      ByVal wParam As Long, lParam As Any) As Long

Public Sub ComboBoxSpeedFill(cmboBox As ComboBox)
   Dim rtn As Long, lngPos As Long
   With cmboBox
      lngPos = Len(.Text)
      If lngPos <> 0 Then
         rtn = SendMessage(.hwnd, &H14C, -1&, ByVal .Text)
         .ListIndex = rtn
         .SelStart = lngPos
         .SelLength = Len(.Text) - lngPos
      End If
   End With
End Sub



See Also: