-
September 30th, 2013, 07:33 AM
#1
show results from a listbox only?
Lets say I have a textbox, and a listbox, and this listbox contains like 300 items, with everything from "apple" to "blue", and lets say you want to look for a particular word, but you dont know the full thing, or maybe you do, but you dont want to type in "supercalafraglisticespealadouchus", so you just type in "supe" and chances are, its going to return maybe 5 items that contain the exact words "supe" in it, and "supercala..." is one of them...
In other words: How would I make the listbox refresh with the new results that only contain those words? I have it set to check what is typed, and display a messagebox, and then clear the list, but I dont know the code to show the results in the listbox that only contain those words.
Heres my code for detecting the words in the listbox:
Code:
Dim files = IO.Directory.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop)
Dim q = From file In files _
Select IO.Path.GetFileName(file)
For Each item In currentdirectorysearch.Items
If currentdirectorysearch.FindString(searchbar.Text) = True Then
MessageBox.Show("That aint even what u typed...")
Else
MessageBox.Show("Thats... Actually what you typed")
End If
Next
(currentdirectorysearch is the listbox, searchbar is the textbox)
Heres my code to populate the listbox, when the application loads:
Code:
Dim files = IO.Directory.GetFiles(My.Computer.FileSystem.SpecialDirectories.Desktop)
Dim q = From file In files _
Select IO.Path.GetFileName(file)
currentdirectorysearch.Items.Clear()
currentdirectorysearch.Items.AddRange(q.ToArray)
Dim i As Long
Dim j As Long
Dim List1
With List1
For i = 0 To .ListCount - 1
For j = .ListCount To (i + 1) Step -1
If .List(j) = .List(i) Then
.RemoveItem(j)
End If
Next
Next
End With
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
|