Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Client Swear Filter With Replaces
#3
GIAKEN Wrote:Unfortunately, it won't work...it will only replace the last swear word in the string. Like this:

Msg = "shit whore fuck bitch" for example...

CheckMessage = "**** whore fuck bitch" but Msg is still the same so it will look for the second swear...so then

CheckMessage = "shit ***** fuck bitch" and then Msg will still equal the same thing...so you do:

Code:
Public Function CheckMessage(byval Msg As String) As String
Dim i As Long
  
    For i = 0 To UBound(SwearArray)
        CheckMessage = Replace$(Msg, SwearArray(i), ReplaceSwearArray(i), , , vbTextCompare)
        If CheckMessage  Msg Then Msg = CheckMessage
    Next i
  
End Function

Also changed i to a Long because it's the fastest type to use for loops.

Ah true, thanks for that first fix, hadn't thought of that. And yeah, I thought of using I as a long for the loop, I'll probably do that Smile. Thanks for that mate Smile
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)