|
-
Aug 6th, 2003, 06:04 AM
#1
Thread Starter
Hyperactive Member
Finding items in a list
Hi,
I'm looking for a code sample (.NET) on vbf. I have previously used it in a project, and since lost it!!
Its the code to Find an item in a listview from the text in a textbox. The code is in the TextChanged event of the textbox and basically finds the item in the listview that it matches - like the "Type name or select from list" textbox works in outlooks address book.
I remember the code was definitely on vbf - and it was more complicated than I'm going to attempt in the time I have to do it....
If anyone could help me find it I'd be very grateful.
Cheers
S.
Another satisfied customer 
-
Aug 6th, 2003, 06:13 AM
#2
Thread Starter
Hyperactive Member
Having spent 3 hours searching this morning... I find the code 30 seconds after posting... isn't that always the case?!!
http://www.vbforums.com/showthread.p...hreadid=200745
(listbox not listview!)
Another satisfied customer 
-
Aug 6th, 2003, 08:31 AM
#3
New Member
Hmm
If i understand you right then this is what you need =)
For I = 0 To List1.ListCount - 1
If List1.List(I) = "My text =)" Then
'Do some stuff
End If
Next I
Hope that helps
-
Aug 6th, 2003, 10:36 AM
#4
Addicted Member
OK so it's not .NET so you will need to adjust the text_change signature and some listbox syntax etc... but my own favorite method for listbox searching - courtesy of ALLAPI !
Code:
'This project needs a ListBox, named List1 and a TextBox, named Text1
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Integer, _
ByVal lParam As Any) As Long
Const LB_FINDSTRING = &H18F
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Add some items to the listbox
With List1
.AddItem "Computer"
.AddItem "Screen"
.AddItem "Modem"
.AddItem "Printer"
.AddItem "Scanner"
.AddItem "Sound Blaster"
.AddItem "Keyboard"
.AddItem "CD-Rom"
.AddItem "Mouse"
End With
End Sub
Private Sub Text1_Change()
'Retrieve the item's listindex
List1.ListIndex = SendMessage(List1.hwnd, LB_FINDSTRING, -1, ByVal CStr(Text1.Text))
End Sub
Last edited by powdir; Aug 6th, 2003 at 10:50 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|