VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Auto-searching by entering text in a combo box

by Eli Elhadad (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 26th May 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Auto-searching by entering text in a combo box

API Declarations


(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Public Const CB_FINDSTRING = &H14C

Rate Auto-searching by entering text in a combo box



  
Private Sub Combo1_Change() 
  Dim iStart As Integer 
  Dim sString As String 
  Static iLeftOff As Integer 
  
  iStart = 1 
  iStart = Combo1.SelStart 
  
  If iLeftOff <> 0 Then 
    Combo1.SelStart = iLeftOff 
    iStart = iLeftOff 
  End If 
  
  sString = CStr(Left(Combo1.Text, iStart)) 
  Combo1.ListIndex = SendMessage(Combo1.hwnd, _ 
  CB_FINDSTRING, -1, ByVal CStr(Left( _ 
  Combo1.Text, iStart))) 
  
  If Combo1.ListIndex = -1 Then 
    iLeftOff = Len(sString) 
    Combo1.Text = sString 
  End If 
  
  Combo1.SelStart = iStart 
  iLeftOff = 0 
End Sub  

Download this snippet    Add to My Saved Code

Auto-searching by entering text in a combo box Comments

No comments have been posted about Auto-searching by entering text in a combo box. Why not be the first to post a comment about Auto-searching by entering text in a combo box.

Post your comment

Subject:
Message:
0/1000 characters