Skip to content

Planet-Source-Code/said-sowiny-advanced-auto-complete-list-combo-and-list-boxs__1-46441

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Advanced Auto Complete List Combo and List Boxs

Description

This is a high class code article

i never be stingy with vb lovers .

I try and success to move the power of access to the power of vb .

The main features are :

  1. the sub can be used with combo box and list box controls.

  2. High performance.

  3. faster with huge lists.

  4. fully support of Delete and Backspace keys.

5)Case Sensitive.

  1. of course few lines of code point to the purpose.

Try it and tell me.

If you found this really advanced please be faithful and vote.

Thanks.

More Info

Submitted On
By Said Sowiny
Level Advanced
User Rating 4.8 (29 globes from 6 users)
Compatibility VB 5.0, VB 6.0
Category Coding Standards
World Visual Basic
Archive File

Source Code

'==================================

Public Sub AutoCompleteList(ByVal cboCtl As ComboBox, ByVal KeyCode As Integer)

'No comments it is clear .

Dim Counter As Integer

Dim Length As Integer

If cboCtl.Text <> "" Then

If KeyCode = vbKeyBack Or KeyCode = vbKeyDelete Then

KeyCode = 0

Exit Sub

End If

For Counter = 0 To cboCtl.ListCount - 1

Length = Len(cboCtl.Text)

If Mid(cboCtl.List(Counter), 1, Len(cboCtl)) = cboCtl.Text Then

cboCtl.Text = cboCtl.List(Counter)

cboCtl.SelStart = Length

cboCtl.SelLength = Len(cboCtl.Text)

cboCtl.ListIndex = Counter

Exit For

End If

Next

End If

End Sub

'===========================================

Typical usage :

Private Sub cboCategory_Change()

Call AutoCompleteList(cboCategory, mintKeyCode)

End Sub

Where mintKeyCode is a form variable given by a Form_KeyDown event like :

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

mintKeyCode = KeyCode

End Sub

and the cboCategory is the combo box filled by your own items.

Taking into consideration the header of the form should look like this one :

Option Explicit

Private mintKeyCode As Integer

and your form KeyPreview Property is set to TRUE.

Enjoy ,

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published