Author : Dipen Anovadia
Date Submitted : 7/4/2006
Category : Microsoft Controls
Compatibility : VB 6,VB 5
This code has been accessed 4364 times.
Task : Begin finding in list box when you begin typing in Textbox
Without any API use. Very easy and with only one procedure...!
Declarations
Code
'Form1 Code
'Ensure all the objects are taken with proper names...
'such as-
'TextBox - txt - textbox for testing
'ListBox - lst - listbox for testing
'Command - btnClose - button for closing app
'Check - chkNoSelOnWrong - checkbox for option-1
'Check - chkResetOnBlank - checkbox for option-2
'...
'Errors, feedbacks, etc...
'dippu75@hotmail.com
Private Sub Form_Load()
Dim l As Long, b As Boolean
lst.AddItem "Dipen"
lst.AddItem "Tropix Game"
lst.AddItem "Tropix Paradise"
lst.AddItem "Daisy"
lst.AddItem "MANDIP infotech"
For l = 5 To 25
b = Not b
lst.AddItem IIf(b, l, "Dipen" & l)
Next l
End Sub
Private Sub txt_Change()
Dim lReturn As Long, lError As Long
lReturn = IndexFromText(lst, txt, , , (chkResetOnBlank.Value And Checked), lError)
If Not (lError = 0) Then Exit Sub
If (chkNoSelOnWrong.Value And Checked) And lReturn = -2 Then lst.ListIndex = -1
If lReturn < -1 Then Exit Sub
If lReturn > lst.ListCount Then Exit Sub
lst.ListIndex = lReturn
End Sub