try this code....
Option Explicit
Private Sub Form_Load()
With Combo1
.AddItem "ABCD"
.AddItem "ACDE"
.AddItem "ADEF"
.AddItem "AEFG"
.AddItem "ACFG"
.AddItem "AFGH"
.AddItem "AGHI"
End With
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
Dim i As Long
Dim iNewStart As Integer
Dim strTemp As String
'Figure out the string prefix to search
' gor
If Combo1.SelStart = 0 Then
strTemp = Combo1.Text & Chr(KeyAscii)
Else
strTemp = Left(Combo1.Text, Combo1.SelStart) & Chr(KeyAscii)
End If
'Pass -1 as lParam to search entire list
'
i = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, strTemp)
'-1 return code indicates failure to fin
' d the string
If i <> -1 Then
'SendMessage returns the index of the fi
' rst occurrence
'of strTemp in the combo's list.
Combo1.Text = Combo1.List(i)
'Set the text selection appropriately fo
' r the
'suggested match
Combo1.SelStart = Len(strTemp)
Combo1.SelLength = Len(Combo1.List(i)) - Len(strTemp)
KeyAscii = 0
End If
End Sub
have nice programming....
