| {\rtf1\ansi\ansicpg1252\deff0\deflang1044{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 This code finds the closest match to what is enter into a text box. \par \par Enter this into the General Declarations of a form: \par \par Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long \par Private Const LB_FINDSTRING = &H18F \par \par \par In the change event of a Text Box control enter: \par \par 'LB_FINDSTRING finds the string that matches most closely \par 'SendMessage takes: \par '1) the hWnd of the list box \par '2) the starting point for the search. -1 is used to search the whole listbox \par '3) a long pointer to the string to find \par lstBox.ListIndex = SendMessage(lstBox.hwnd, LB_FINDSTRING, -1, ByVal Text1.Text) \par \par \par Rename lstBox to the name of your list box and Text1 to the name of the text box. \par \par When you type in the text box the closest match will be selected in the list box. \par \par } |
Auto-searching a List Box |
India web developer web development India | India web development company India ecommerce web developer