[RESOLVED] help with 2 list box checking if contains
having little trouble detecting
list1 items
site1.com
site2.com
site3.com
list2 items
<a href="http://www.site1.com/">free- Free general Directory</a>
<a href="http://www.site2.com/">red- Free turn Directory</a>
using this code now
Code:
Dim BoolAdd As Boolean, i As Long, J As Long
On Error Resume Next
For i = List1.ListCount - 1 To 0 Step -1
For J = 0 To List2.ListCount
If List1.List(i) = List2.List(J) Then
List1.RemoveItem (i)
Exit For
End If
DoEvents
Next J
DoEvents
Next i
cant get it to work because list2 has < > and other chars please help
Re: help with 2 list box checking if contains
I believe you already know how to use InStr, right? ;)
Re: help with 2 list box checking if contains
For i = List1.ListCount - 1 To 0 Step -1
For J = 0 To List2.ListCount
If InStr(List1.List(i), List2.list(i)) Then
List2.RemoveItem (i)
Exit For
End If
DoEvents
Next J
DoEvents
Next i
not happening
tried
Dim i As Integer
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), "site2.com") Then
List1.Selected(i) = True
MsgBox "Item #" & (i + 1) & " is what you searched for"
'Select the found entry
List1.ListIndex = i
End If
Next
it works but the line were it shows "site2.com") Then need to add list2.list(i) something like that to scan all list2 and match
Re: help with 2 list box checking if contains
Refer to the link I've given. Read carefully the descriptions of the string1 and string2 parameters. You'll then see why it didn't work. :cool:
Re: help with 2 list box checking if contains
:(comon just little stuck want to get out of the mud hole am in and move on:(
Re: help with 2 list box checking if contains
taraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
done it
Code:
Private Sub Command17_Click()
Dim i As Integer, x As Integer
For i = 0 To List4.ListCount - 1
For x = 0 To List5.ListCount - 1
If InStr(List4.List(i), List5.List(x)) > 0 Then
'If InStr(List4.List(i), List5.List(i)) Then
List5.RemoveItem (x)
Exit For
End If
Next
Next
End Sub
Re: [RESOLVED] help with 2 list box checking if contains
Just swap the arguments:
Code:
If InStr(List2.List(J), List1.List(i)) Then
Note List2's J index. ;)
Re: [RESOLVED] help with 2 list box checking if contains
There are more than just the one obvious mistake. I've corrected it
Code:
If InStr(List2.List(j), List1.list(i)) Then