dcsimg
 

VB TIP: Using Auto Complete

by Karl Moore

One of the latest user interface fads is AutoComplete, a feature Microsoft introduced with Internet Explorer 5. With this code snippet, learn how to instantly add it to your application — simplifying the typing of filenames, folders and Web addresses!

One of the latest user interface fads is AutoComplete, a feature Microsoft introduced with Internet Explorer 5.

Since it's birth, numerous Visual Basic sites have attempted to duplicate such functionality by using special combo box algorithms, API search procedures and such like. This code snippet doesn't. Instead, it uses the exact same API call as the software giant.

That means you can simplify the typing of Web addresses, automatically complete file and folder names, plus display command lines tapped direct into the Run menu — all with the use of this special function.

To use this code snippet, simply add a Text Box to your Form, then call the MakeAutoComplete method, passing your Text Box as an argument.

Note: This code requires Internet Explorer 5 to work. To check whether your user has Internet Explorer 5 installed, use the code tip here.

Usage

Call MakeAutoComplete(Text1)

Code

Private Declare Function SHAutoComplete _
   Lib "Shlwapi.dll" _
  (ByVal hwndEdit As Long, _
   ByVal dwFlags As Long) As Long

Private Const SHACF_DEFAULT  As Long = &H0

Public Sub MakeAutoComplete(ByRef TextB As TextBox)

    Call SHAutoComplete(TextB.hWnd, SHACF_DEFAULT)

End Sub
This article was originally published on Tuesday Nov 19th 2002
Home
Mobile Site | Full Site