Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Procedure which uses the SendMessage API to search...
Author:
Justin Manley
Submitted:
1/15/2000
Version:
VB5
Compatibility:
VB5,6
Category:
Windows API
Views:
15599
Procedure which uses the SendMessage API to search a List Box for a specific piece of text. The text is highlighted as the user types in a textbox.
Declarations:
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Code:
Private Sub txtSearch_Change() Dim TempString As String Dim TheHandle As Long Dim Position As Long TempString = txtSearch.Text TheHandle = lstBox.hwnd If Len(TempString) = 0 Then 'search box is empty lstBox.ListIndex = 0 Else 'set list index to matching entry or back to first if nothing found Position = SendMessage(TheHandle, LB_FINDSTRING, -1, TempString) If Position = -1 Then lstBox.ListIndex = 0 Else lstBox.ListIndex = Position End If End If End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement