• Welcome to Valhalla Legends Archive.
 

Sorry another EASY question

Started by Gangz, October 15, 2003, 09:55 PM

Previous topic - Next topic

Gangz

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

the ban command is

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

and the function code is.....

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


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

Edit: Use code tags please.

iago

This line doesn't look right..
QuoteIf matches(username, listview.listitems.item(lvChannel.Listitems.count).Text) = True Then

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.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


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...

iago

Shouldnt' you go through the channel list and check it against every user in that channel?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


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

Banana fanna fo fanna

What's your PrepareCheck() function?

Also, you never have to test if something = True.

Lenny

#6
Quote from: Gangz on October 16, 2003, 03:20 AM
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
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:

Left(text after "ban ", Instr(text after "ban ", "*") - 1)

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)
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

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.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Gangz

yep iago i got it!!! thanks to every that helped !!! :P :P

Soul Taker

Are you from New York by any chance, Gangz?

Gangz

Soul taker no im from vegas...

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.

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.

Soul Taker

Quote from: Gangz on October 19, 2003, 12:34 AM
Soul taker no im from vegas...
I wanted to call you Gangz of New York =P

SiMi


hismajesty

Quote from: Soul Taker on October 19, 2003, 12:52 PM
Quote from: Gangz on October 19, 2003, 12:34 AM
Soul taker no im from vegas...
I wanted to call you Gangz of New York =P

* hismajesty saw that coming a mile away.