I am trying to use the following code to auto fill a combo box
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(ByVal theCombo As ComboBox, ByVal theKey As
Keys)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String
Select Case theKey
Case Keys.Back, Keys.Left, Keys.Right, Keys.Delete, Keys.Down
Return
End Select
With theCombo
sTypedText = .Text
iFoundIndex = .FindString(sTypedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIndex)
sFoundText = .GetItemText(oFoundItem)
sAppendText = sFoundText.Substring(sTypedText.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Length
.SelectionLength = sAppendText.Length
End If
End With
End Sub
The problem is this: If I have the name John in my combo box and type
in john (that is, using a small letter j not J), it automatically
fills the box with the John not john. I checked sTypedText just before
the .Text assignment and it is small letter j. So when .Text is set,
it seems to find the John entry and uses it..or something...what am I
missing here?
TIA,
John