kalaka
asked on
Using Wildcards #2
Ok, I asked a question about two days ago about wildcards. I have a problem with the wildcarding but now im using a ListView [code]
UserSearch = Right(Message, Len(Message) - 5)
If Right(UserSearch, 1) = "*" Or Left(UserSearch, 1) = "*" Then
Dim UserWild As String, i As Integer
For i = ChannelLst.ListItems.Count - 1 To 0 Step -1
UserWild = Left(UserSearch, Len(UserSearch) - 1)
If InStr(1, ChannelLst.ListItems.Item( i), Replace(UserWild, "*", ""), _
vbTextCompare) > 0 Then
Call GetAccess(sAccess, ChannelLst.ListItems.Item( i).Text)
If sAccess < intAccess Then
buffer.send "/kick " & ChannelLst.ListItems.Item( i).Text & " " & UserSearch
End If
ElseIf InStr(1, ChannelLst.ListItems.Item( i), "*", vbTextCompare) = 0 Then
If LCase(ChannelLst.ListItems .Item(i)) = LCase(UserSearch) Then
buffer.send "/kick " & ChannelLst.ListItems.Item( i) & " " & UserSearch
End If
End If
Next
End If
[/code]
The following error appears when there is no Item in the ListView that matches the wildcard: "Run-time error: 35600 - Index out of bounds" and it selects the text :
If InStr(1, ChannelLst.ListItems.Item( i), Replace(UserWild, "*", ""), vbTextCompare) > 0 Then
UserSearch = Right(Message, Len(Message) - 5)
If Right(UserSearch, 1) = "*" Or Left(UserSearch, 1) = "*" Then
Dim UserWild As String, i As Integer
For i = ChannelLst.ListItems.Count
UserWild = Left(UserSearch, Len(UserSearch) - 1)
If InStr(1, ChannelLst.ListItems.Item(
vbTextCompare) > 0 Then
Call GetAccess(sAccess, ChannelLst.ListItems.Item(
If sAccess < intAccess Then
buffer.send "/kick " & ChannelLst.ListItems.Item(
End If
ElseIf InStr(1, ChannelLst.ListItems.Item(
If LCase(ChannelLst.ListItems
buffer.send "/kick " & ChannelLst.ListItems.Item(
End If
End If
Next
End If
[/code]
The following error appears when there is no Item in the ListView that matches the wildcard: "Run-time error: 35600 - Index out of bounds" and it selects the text :
If InStr(1, ChannelLst.ListItems.Item(
Use like for wild cards its very easy.
-Brian
-Brian
ASKER
The problem isnt with the method I'm using to compare the text, its with the index. Apparently ListViews work differently
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dim string1 as string
dim string2 as string
string1 = "briangeff719"
string2 = "briangeff719"
if string1 like "brian*" then
msgbox "string has brian as the start"
end if
if string like "*geff*" then
msgbox "string contains geff"
end if
good luck
-Brian