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(B yVal 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(sTy pedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIn dex)
sFoundText = .GetItemText(oF oundItem)
sAppendText = sFoundText.Subs tring(sTypedTex t.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Leng th
.SelectionLengt h = sAppendText.Len gth
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...wha t am I
missing here?
TIA,
John
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(B yVal 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(sTy pedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIn dex)
sFoundText = .GetItemText(oF oundItem)
sAppendText = sFoundText.Subs tring(sTypedTex t.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Leng th
.SelectionLengt h = sAppendText.Len gth
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...wha t am I
missing here?
TIA,
John
Comment