- Код: Выделить всё
Private Const CB_FINDSTRING = &H14C&
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Sub AutoFillCombo(Combo As ComboBox)
Dim I&, P&
I = SendMessage(Combo.hWnd, CB_FINDSTRING, -1, ByVal Combo.Text) + 1
If I > 0 Then
P = Combo.SelStart
Combo.ListIndex = I - 1
Combo.SelStart = P
Combo.SelLength = Len(Combo.Text) - P
End If
End Sub
- Код: Выделить всё
Option Explicit
Private Const CB_FINDSTRING = &H14C&
Private Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)
Private LastComboKeyAscii&
Sub AutoFillCombo(Combo As ComboBox)
Dim I&, P&
I = SendMessage(Combo.hWnd, CB_FINDSTRING, -1, ByVal Combo.Text) + 1
If I > 0 Then
P = Combo.SelStart
Combo.ListIndex = I - 1
Combo.SelStart = P
Combo.SelLength = Len(Combo.Text) - P
End If
End Sub
Private Sub Combo1_Change()
If Not (LastComboKeyAscii = 8) And Not (LastComboKeyAscii = 46) Then AutoFillCombo Combo1
LastComboKeyAscii = 0
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
LastComboKeyAscii = KeyCode
End Sub
Private Sub Command1_Click()
Combo1.AddItem Text1.Text
End Sub
vbskb_combo vbskb_search vbskb_find vbskb_sample