by Ken Power (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 30th January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Orginal written by Muhammad Musa Ali then simplified by me. This is a simplified Combo Box Auto Fill
API Declarations
In the combobox change event do this
Proc_ComboAutoFill cboYourCombo
Dim i As Integer
Dim szEntry As String
If cboCtl.SelStart = 0 Then
szEntry = cboCtl.Text
Else
szEntry = Left$(cboCtl.Text, cboCtl.SelStart)
End If
If IsNull(szEntry) Or Len(szEntry) < 1 Then Exit Sub
If cboCtl.ListCount = 0 Then Exit Sub
i = Func_ListSearch(cboCtl, szEntry)
If i <> -1 Then
cboCtl.ListIndex = i
cboCtl.SelStart = Len(szEntry)
cboCtl.SelLength = Len(cboCtl.List(i)) - Len(szEntry)
Exit Sub
Else
cboCtl.Text = szEntry
Exit Sub
End If
End Sub
Private Function Func_ListSearch(ctlList As Control, szSearch As String) As Integer
Dim LoPt As Integer
Dim HiPt As Integer
Dim CmpVal As Integer
LoPt = 0
HiPt = ctlList.ListCount
Do While LoPt < HiPt
CmpVal = StrComp(UCase$(Left$(ctlList.List(LoPt), Len(szSearch))), UCase$(szSearch))
If 0 = CmpVal Then
Exit Do
Else
LoPt = LoPt + 1
End If
Loop
If CmpVal <> 0 Then
LoPt = -1
End If
Func_ListSearch = LoPt
End Function
No comments have been posted about Orginal written by Muhammad Musa Ali then simplified by me. This is a simplified Combo Box Auto Fil. Why not be the first to post a comment about Orginal written by Muhammad Musa Ali then simplified by me. This is a simplified Combo Box Auto Fil.