Code: Select all
Private miSelStart As Integer
Private Sub CCOMRIL_KeyDown(KeyCode As Integer, Shift As Integer)
'<Delete>
If KeyCode = 46 Then KeyCode = 0 'Disable the delete key
miSelStart = Me.CCOMRIL.SelStart
End Sub
Private Sub CCOMRIL_KeyPress(KeyAscii As Integer)
Dim lCnt As Long 'Generic long counter
Dim lMax As Long
Dim sComboItem As String
Dim sComboText As String 'Text currently in combobox
Dim sText As String 'Text after keypressed
With CCOMRIL
lMax = .ListCount - 1
sComboText = .Text
sText = Left(sComboText, miSelStart) & Chr(KeyAscii)
KeyAscii = 0 'Reset key pressed
For lCnt = 0 To lMax
sComboItem = .List(lCnt)
If UCase(sText) = UCase(Left(sComboItem, _
Len(sText))) Then
.ListIndex = lCnt
.Text = sComboItem
.SelStart = Len(sText)
.SelLength = Len(sComboItem) - (Len(sText))
Exit For
End If
Next 'lCnt
End With
End Sub
i need to use a find string in a part of listitem, in my case from string between - and -
my list:
401001001 - AGLIE' - TO
401001002 - AIRASCA - TO
...
401001012 - ARIGNANO - TO