23-09-2008, 02:56 AM
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:
Also changed i to a Long because it's the fastest type to use for loops.
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.