IncrSearchCombo




'AutoSearch Combo1, KeyAscii

'Usare la dichiarazione seguente:


Const CB_ERR = -1
Const CB_FINDSTRING = &H14C

Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal WParam As Long, _
lParam As Any) As Long

'Questa e' la Subroutine:


Sub AutoSearch (cbo As ComboBox, KeyAscii As Integer)
Dim sBuffer As String
Dim lRetVal As Long

sBuffer = Left(cbo.Text, cbo.SelStart) & Chr(KeyAscii)
lRetVal = SendMessage((cbo.hWnd), CB_FINDSTRING, -1, _
ByVal sBuffer)

If lRetVal <> CB_ERR Then
cbo.ListIndex = lRetVal
cbo.Text = cbo.List(lRetVal)
cbo.SelStart = Len(sBuffer)
cbo.SelLength=Len(cbo.Text)
KeyAscii = 0
End If
End Sub Usare il codice seguente nell'evento keypress del controllo
combo box:










( incrsearchcombo.html )- by Paolo Puglisi - Modifica del 17/12/2023