Ed Duval
Nov 11th, 1999, 07:39 AM
I am trying to create a type-ahead which is similar to the "Microsoft Money" look and feel.
I am using a combo-box and essentially have everything worked out by using the KeyPress event. The problem I am having is that the keypress event does not give me the .selposition upon entry. I need to find out where the cursor is within the text of the combo box, hopefully without attempting to track all arrow keys and backspaces, ect.
Does anyone no of any examples or have any code to locate the cursor postion within the combo text?
Here is my code so far:
Private Sub BatchCombo_KeyPress(Index As Integer, KeyAscii As Integer)
ProcessCombo BatchCombo(Index), KeyAscii
KeyAscii = 0
End Sub
Sub ProcessCombo(TestCombo As Control, KeyAscii As Integer)
Dim strText As String
Dim intCtr As Integer
If Len(TestCombo.Tag) > Len(TestCombo.Text) Then TestCombo.Tag = TestCombo.Text
If KeyAscii = 8 Then
If Len(TestCombo.Tag) > 0 Then
TestCombo.Tag = Left(TestCombo.Tag, Len(TestCombo.Tag) - 1)
End If
Else
TestCombo.Tag = TestCombo.Tag + Chr(KeyAscii)
End If
TestCombo.Text = TestCombo.Tag
For intCtr = 0 To TestCombo.ListCount - 1
If UCase(TestCombo.Tag) = UCase(Left(TestCombo.List(intCtr), Len(TestCombo.Tag))) Then
TestCombo.Text = TestCombo.List(intCtr)
TestCombo.SelStart = Len(TestCombo.Tag)
Exit Sub
End If
Next intCtr
TestCombo.Text = TestCombo.Tag
End Sub
I am using a combo-box and essentially have everything worked out by using the KeyPress event. The problem I am having is that the keypress event does not give me the .selposition upon entry. I need to find out where the cursor is within the text of the combo box, hopefully without attempting to track all arrow keys and backspaces, ect.
Does anyone no of any examples or have any code to locate the cursor postion within the combo text?
Here is my code so far:
Private Sub BatchCombo_KeyPress(Index As Integer, KeyAscii As Integer)
ProcessCombo BatchCombo(Index), KeyAscii
KeyAscii = 0
End Sub
Sub ProcessCombo(TestCombo As Control, KeyAscii As Integer)
Dim strText As String
Dim intCtr As Integer
If Len(TestCombo.Tag) > Len(TestCombo.Text) Then TestCombo.Tag = TestCombo.Text
If KeyAscii = 8 Then
If Len(TestCombo.Tag) > 0 Then
TestCombo.Tag = Left(TestCombo.Tag, Len(TestCombo.Tag) - 1)
End If
Else
TestCombo.Tag = TestCombo.Tag + Chr(KeyAscii)
End If
TestCombo.Text = TestCombo.Tag
For intCtr = 0 To TestCombo.ListCount - 1
If UCase(TestCombo.Tag) = UCase(Left(TestCombo.List(intCtr), Len(TestCombo.Tag))) Then
TestCombo.Text = TestCombo.List(intCtr)
TestCombo.SelStart = Len(TestCombo.Tag)
Exit Sub
End If
Next intCtr
TestCombo.Text = TestCombo.Tag
End Sub