January 27, 2021
Hot Topics:

VB TIP: Using Auto Complete

  • By Karl Moore
  • Send Email »
  • More Articles »

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.


Call MakeAutoComplete(Text1)


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 November 19, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date