Valhalla Legends Forums Archive | Battle.net Bot Development | Sorry another EASY question

AuthorMessageTime
Gangz
i feel dumb for asking so much but i cant get this code to work for wildcards....

the ban command is
[code]
If Left(Message, 4) = (Trigger & "ban") Then
If matches(username, listview.listitems.item(lvChannel.Listitems.count).Text) = True Then
GoTo Ban
End if
End if
[/code]
and the function code is.....
[code]
Public Function matches(ByVal uName As String, ByVal Check As String) As Boolean
Call PrepareCheck(Check)
If uName = Empty Then
matches = False
Exit Function
End If
If LCase$(uName) Like LCase$(Check) Then matches = True
End Function
[/code]

Do you guys see any reason why this will not work?

Edit: Use code tags please.
October 16, 2003, 2:55 AM
iago
This line doesn't look right..
[quote]If matches(username, listview.listitems.item(lvChannel.Listitems.count).Text) = True Then[/quote]

I don't think you're checking the right index, item(...count) doesn't seem to make sense, you have to loop through all the users in the channel.
October 16, 2003, 4:59 AM
Gangz
I have tried all possible solutions i can find that would make it look through but i think i am missing soemthine to make it realize the * is in there as a wildcard...
October 16, 2003, 5:35 AM
iago
Shouldnt' you go through the channel list and check it against every user in that channel?
October 16, 2003, 5:50 AM
Gangz
Yea but First i have to make it realize that the * means to call the function that checks it against ever name in the channel...It' onyl finding the * as part of the name not a variable
October 16, 2003, 8:20 AM
St0rm.iD
What's your PrepareCheck() function?

Also, you never have to test if something = True.
October 17, 2003, 12:38 AM
Lenny
[code][/code][quote author=Gangz link=board=17;threadid=3109;start=0#msg24339 date=1066292457]
Yea but First i have to make it realize that the * means to call the function that checks it against ever name in the channel...It' onyl finding the * as part of the name not a variable
[/quote]
Couldnt you do an Instr(text after "ban ", "*"), if the value return is >0 then "*" is found. Then to isolate the wildcard from "*" you would do:
[code]
Left(text after "ban ", Instr(text after "ban ", "*") - 1)
[/code]
Then compare this value with the users in the channel list....

(the number of characters to compare up to would depend of the length of the wildcard)
October 17, 2003, 3:26 AM
iago
Lenny - it's possible, but VB already created an operator for doing that, "like".

if "john" like "j*n" would, apparently, return true.

It's not terribly efficiant, but it works I'm told :)

He's just using it wrong, only checking the last user in the channel (he has to loop!) but he'll figure it out eventually.
October 17, 2003, 3:37 AM
Gangz
yep iago i got it!!! thanks to every that helped !!! :P :P
October 17, 2003, 5:27 AM
Soul Taker
Are you from New York by any chance, Gangz?
October 17, 2003, 4:11 PM
Gangz
Soul taker no im from vegas...
October 19, 2003, 5:34 AM
bmwrb16
Some extra information about the like operator thanks to MSDN

Syntax:

result = string Like pattern

The Like operator syntax has these parts:

Part - Description
result - Required; any numeric variable.
string - Required; any string expression.
pattern - Required; any string expression conforming to the pattern-matching conventions described in Remarks.

Remarks

If string matches pattern, result is True; if there is no match, result is False. If either string or pattern is Null, result is Null.

The behavior of the Like operator depends on the Option Compare statement. The default string-comparison method for each module is Option Compare Binary.

Option Compare Binary results in string comparisons based on a sort order derived from the internal binary representations of the characters. Sort order is determined by the code page. In the following example, a typical binary sort order is shown:

A < B < E < Z < a < b < e < z < < < < < <

Option Compare Text results in string comparisons based on a case-insensitive, textual sort order determined by your system's locale. When you sort The same characters using Option Compare Text, the following text sort order is produced:

(A=a) < (=) < (B=b) < (E=e) < (=) < (Z=z) < (=)

Built-in pattern matching provides a versatile tool for string comparisons. The pattern-matching features allow you to use wildcard characters, character lists, or character ranges, in any combination, to match strings. The following table shows the characters allowed in pattern and what they match:

Characters in pattern Matches in string
? - Any single character.
* - Zero or more characters.
# - Any single digit (09).
[charlist] - Any single character in charlist.
[!charlist] - Any single character not in charlist.

[code]Dim MyCheck
MyCheck = "aBBBa" Like "a*a" ' Returns True.
MyCheck = "F" Like "[A-Z]" ' Returns True.
MyCheck = "F" Like "[!A-Z]" ' Returns False.
MyCheck = "a2a" Like "a#a" ' Returns True.
MyCheck = "aM5b" Like "a[L-P]#[!c-e]" ' Returns True.
MyCheck = "BAT123khg" Like "B?T*" ' Returns True.
MyCheck = "CAT123khg" Like "B?T*" ' Returns False.[/code]
October 19, 2003, 5:35 PM
Soul Taker
[quote author=Gangz link=board=17;threadid=3109;start=0#msg24564 date=1066541690]
Soul taker no im from vegas...
[/quote]
I wanted to call you Gangz of New York =P
October 19, 2003, 5:52 PM
SiMi
[quote author=Soul Taker link=board=17;threadid=3109;start=0#msg24609 date=1066585924]
[quote author=Gangz link=board=17;threadid=3109;start=0#msg24564 date=1066541690]
Soul taker no im from vegas...
[/quote]
I wanted to call you Gangz of New York =P
[/quote]
Gangz of Las Vegas
October 19, 2003, 9:27 PM
hismajesty
[quote author=Soul Taker link=board=17;threadid=3109;start=0#msg24609 date=1066585924]
[quote author=Gangz link=board=17;threadid=3109;start=0#msg24564 date=1066541690]
Soul taker no im from vegas...
[/quote]
I wanted to call you Gangz of New York =P
[/quote]

[me=hismajesty]saw that coming a mile away.[/me]
October 19, 2003, 9:56 PM
Adron
[quote author=bmwrb16 link=board=17;threadid=3109;start=0#msg24607 date=1066584956]
Option Compare Text results in string comparisons based on a case-insensitive, textual sort order determined by your system's locale. When you sort The same characters using Option Compare Text, the following text sort order is produced:

(A=a) < (=) < (B=b) < (E=e) < (=) < (Z=z) < (=)

[/quote]


What about ä å ö ?
October 19, 2003, 10:26 PM

Search