Purge Characters from String


Function StringPurgeChars(strIn As String, strCharsToPurge As String) As String
'Remove from strIn all Chars which appear in strCharsToPurge
'Testcases
'?StringPurgeChars("abbc", "") = "abbc"
'?StringPurgeChars("a", "b") = "a"
'?StringPurgeChars("abbc", "bc") = "a"
'?StringPurgeChars("b", "bc") = ""
'?StringPurgeChars("", "bc") = ""
 Dim i As Long
 Dim strChar As String
    For i = 1 To Len(strIn)
        strChar = Mid$(strIn, i, 1)
        If InStr(1, strCharsToPurge, strChar) = 0 Then 
        	StringPurgeChars = StringPurgeChars & strChar
        End If
    Next
End Function