|
-
Jun 14th, 2013, 02:35 AM
#1
Thread Starter
Banned
[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
-
Jun 14th, 2013, 02:59 AM
#2
Re: help with 2 list box checking if contains
I believe you already know how to use InStr, right?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jun 14th, 2013, 03:04 AM
#3
Thread Starter
Banned
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
Last edited by ladoo; Jun 14th, 2013 at 03:09 AM.
-
Jun 14th, 2013, 03:11 AM
#4
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jun 14th, 2013, 03:18 AM
#5
Thread Starter
Banned
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
-
Jun 14th, 2013, 03:24 AM
#6
Thread Starter
Banned
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
-
Jun 14th, 2013, 03:28 AM
#7
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jun 14th, 2013, 03:35 AM
#8
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
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
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
|