Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Wildcards #2

Posted on 2004-04-06
5
Medium Priority
?
240 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:kalaka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10772428
You can use the Like() Command very easily.


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
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10772431
Use like for wild cards its very easy.

-Brian
0
 

Author Comment

by:kalaka
ID: 10798046
The problem isnt with the method I'm using to compare the text, its with the index. Apparently ListViews work differently
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 10823794
PAQd, 70 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question