VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

ComboTypeAhead

Rick Lotter  (1 Submission)   VB function enhancement   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

Allows the VB combobox to have a type-ahead feature like the combobox in Access.
If there are any matching items in the combobox list, it will automatically
"fill in" the missing portions of the item and select it.
This will work for multiple characters, not just the first character of the string.
*** This is an expanded version of the original code ***
The updates allow for new items to be added into the list, automatically. It also
will handle the delete key (the previous code did not.)

Inputs
The combobox that you want to scan for entries in its list. Optionally, you can specify whether the comparison is case-sensitive.

Assumes
The function should be called as following (assuming a combobox call cboMine): Private Sub cboMine_Change() 'If the last key was not a special key (control), then use typeahead function If intLastKey >= 32 Then Call Combo_TypeAhead(cboMine) End Sub Private Sub cboMine_KeyDown(KeyCode As Integer, Shift As Integer) 'If the last key was a delete, then send a backspace to clear the selection If KeyCode = vbKeyDelete Then SendKeys "{BACKSPACE}", True End Sub Private Sub cboMine_KeyPress(KeyAscii As Integer) 'Sets the last key value for control character checking intLastKey = KeyAscii End Sub Private Sub cboMine_LostFocus() Call Combo_AddNew(cboMine) End Sub

Returns
n/a

API Declarations
Private intLastKey As Integer ' Records last keypress

Rate ComboTypeAhead (3(3 Vote))
ComboTypeAhead.bas

ComboTypeAhead Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters