|
-
Jun 15th, 2002, 05:58 AM
#1
Thread Starter
Hyperactive Member
difficult - list, split, search?? <solved>
I have a listbox which contains a lot of documents and file titles which can range to be anything just about.
I need to be able to search the listbox with my string but not search word for word same case, but to search each letter in the item on the entire list.
For instance... say im looking for "Machine" and in my list I have
Fox runs fast
big brown bear
great_white dear
redmachine of time
etc...
I need to be able to pick up "machine" from the 4th item down...
Since I had no idea how to do this, I tried to split each item (by the spaces) then search for the parts using:
Code:
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
List1.List(i) = Split(List1.List(i), " ")
If Text1.Text = List1.List(i) Then
List1.Selected(i) = True
Exit For
End If
Next
End Sub
but not fully sure on how I can split each one and if possible, it needs to be more of a defined way of doing it, eg the way I showed at the start - but if someone knows how I can search it using my split idea with the spaces, that would be great as well 
Thanks
sac
Last edited by Sacofjoea; Jun 15th, 2002 at 03:00 PM.
-
Jun 15th, 2002, 06:05 AM
#2
Thread Starter
Hyperactive Member
also this does not work:
Code:
For i = 0 To List1.ListCount - 1
spltme = List1.List(i)
MsgBox spltme
compairme = Split(spltme, " ")
If Text1.text = compairme Then
List1.Selected(i) = True
Exit For
End If
Next
which I tried to put it into a variable then compair it, but i get a 'Type Mismatch' when I attempt to compair it or even try to view the variable 'compairme'
-
Jun 15th, 2002, 06:11 AM
#3
Thread Starter
Hyperactive Member
argh, perhaps i should learn how to use commands before I attempt them lol
Code:
Dim Compairme() As String
For i = 0 To List1.ListCount - 1
spltme = List1.List(i)
chrs = Len(spltme)
Compairme = Split(spltme, " ")
For z = 0 To chrs
If Text1.text = Compairme(z) Then
List1.Selected(i) = True
Exit For
End If
Next z
Next
prob now is, 'Subscript out of range' ?? at the comparison part with text1.text and compairme(z)
im sleepy must be why im catching these things like a min after i post
-
Jun 15th, 2002, 06:13 AM
#4
Thread Starter
Hyperactive Member
ok the prob that isn't working is because im finding all of the chars in the string when I need to be finding all of the words seperated by spaces (or so I think is why)
gonna leave it at that and get some sleep
any help appreciated 
sac
-
Jun 15th, 2002, 01:29 PM
#5
Thread Starter
Hyperactive Member
so anyone have any ideas??
-
Jun 15th, 2002, 01:45 PM
#6
-
Jun 15th, 2002, 02:56 PM
#7
Thread Starter
Hyperactive Member
thanks, works very well
Code:
For i = 0 To List1.ListCount - 1
spltme = List1.List(i)
'strng = what you are searching for...
Compairme = InStr(spltme, strng)
'if your string is found...
If Compairme > 0 Then
List1.Selected(i) = True
Exit For
End If
Next i
Last edited by Sacofjoea; Jun 15th, 2002 at 02:59 PM.
-
Jun 15th, 2002, 03:01 PM
#8
-
Jun 15th, 2002, 03:04 PM
#9
-
Jun 15th, 2002, 03:33 PM
#10
Thread Starter
Hyperactive Member
lol well didn't want anyone to write the code, just needed an idea/method of doing it - which you gave me 
sac
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
|