vb 6 两个listbox对比问题。

来源:百度知道 编辑:UC知道 时间:2024/06/28 00:25:42
list1
功夫[2007动作大片]|http://功夫/cd1.rm
功夫[2007动作大片]|http://功夫/cd2.rm
.....
.....
list2
http://功夫/cd1.rm$http://功夫/cd2.rm
http://导火线/cd1.rm$http://导火线/cd2.rm
......
.....
在list2中模糊查询比如功夫的那个http地址是否存在list2中。存在的话就从list1中清除

Public Function GetURL(ByVal s As String)
With CreateObject("VBScript.RegExp")
.Pattern = "(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)"
GetURL = .Execute(s)(0).Value
End With
End Function

Private Sub Command1_Click()
Dim i, j As Integer, sURL As String

For i = List1.ListCount - 1 To 0 Step -1
sURL = GetURL(List1.List(i))

For j = 0 To List2.ListCount - 1
If InStr(1, List2.List(j), sURL, vbTextCompare) <> 0 Then
List1.RemoveItem (i)
Exit For
End If
Next j
Next i

MsgBox "OK"
End Sub

怎么 模糊查询 = =都有HTTP。还有 排除 一些 麻烦些。