Search Tools Links Login

AutoComplete Made EASY!


This small script simply and easly creates an AutoComplete affect for your ComboBox. VERY EFFECTIVE AND VERY EASY TO UNDERSTAND.

Original Author: Justin Stevens

Assumptions

This code can be further inhanced by using
If Ucase(.text) = Ucase(......
I will leave the rest for you to discover and learn, but I think you will agree that this code is very promising, flawless and alot less complicated then all the other AutoCompleters!

Returns

The code returns the text that the use inputs into the combo box followed by the AutoCompleted text which is highlighted.
EG)
The user types "F"
The ComboBox then Displays a normal "F" which is then followed by "rog" which is highlighted to give "Frog" where "rog" is the .seltext. Understand?
NOTE: This is not hard to explain, sorry if you do not get what I am saying :)

Code

Private Sub ComboBox_KeyPress(KeyAscii As Integer)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
On Error GoTo Oops
With ComboBox
Kounter = 0
For Kounter = 0 To .ListCount
If .Text = Left(.List(Kounter), Len(.Text)) Then
OldLength = Len(.Text)
.Text = .List(Kounter)
.SelStart = OldLength
.SelLength = Len(.Text) - OldLength
Timer1.Enabled = False
GoTo Oops
End If
Next Kounter
End With
Oops:
Timer1.Enabled = False
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 97 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.