like thisThis code snippet turns a normal combobox into an autocomplete combo like the Internet Explorer Address Bar. Code:Private Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long Private Const CB_FINDSTRING = &H14C Private blnDelete As Boolean Private Sub Combo1_Change() Dim nRet As Long Dim nSelStart As Long If blnDelete Then Exit Sub nRet = SendMessageString(Combo1.hwnd, CB_FINDSTRING, 0, Combo1.Text) Debug.Print Combo1.Text nSelStart = Combo1.SelStart If nRet >= 0 Then Combo1.ListIndex = nRet Combo1.SelStart = nSelStart Combo1.SelLength = Len(Combo1.Text) End If End Sub Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case vbKeyDelete, vbKeyBack blnDelete = True Case Else blnDelete = False End Select End Sub
Private Const CB_FINDSTRING = &H14C
Private blnDelete As Boolean Private Sub Combo1_Change()
Dim nRet As Long
Dim nSelStart As Long
If blnDelete Then Exit Sub
nRet = SendMessageString(Combo1.hwnd, CB_FINDSTRING, 0, Combo1.Text)
Debug.Print Combo1.Text
nSelStart = Combo1.SelStart
If nRet >= 0 Then
Combo1.ListIndex = nRet
Combo1.SelStart = nSelStart
Combo1.SelLength = Len(Combo1.Text)
End If
End Sub Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyDelete, vbKeyBack
blnDelete = True
Case Else
blnDelete = False
End Select
End Sub