This example shows how to make a combo box act like those found in Quickenor Microsoft Access, without using a third-party VBX. As each characteris typed, the elements in the combo box are searched and, if a match isfound, retrieved. If a match is not found, the original typed text is restored.The only code needed resides in the KeyUp event of a combo box called combo1.The combo box is sorted alphabetically, so it stops on the first alphabeticalmatch. I use the SendMessage API to turn the redraw of the combo box offand then on when the search is complete. Here are the form-level declarations for the combo box:
Dim strCombo As StringConst WM_SETREDRAW = &HBConst KEY_A = 65Const KEY_Z = 90Declare Function SendMessage Lib "User" _ (ByVal hWnd As Integer, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ lParam As Any) As Long
The code in the KeyUp event looks like this:
Dim x%Dim strTemp$Dim nRet&If Keycode >= KEY_A And Keycode