Microsoft & .NETVisual BasicVB TIP: Using Auto Complete

VB TIP: Using Auto Complete

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

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

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories