vbCommon – stripIllegalChars

Private Function stripIllegalChars(strTest As String)
Dim strTemp, testThis As String
Dim kount As Integer

strTemp = ""
strTest = Trim(strTest)
For kount = 1 To Len(strTest)
testThis = Mid(strTest, kount, 1)
If InStr(".|\/?*:<>' ", testThis) > 0 Or Asc(testThis) < 32 Or Asc(testThis) = 34 Or Asc(testThis) > 129 Then
 'strTemp = strTemp & "_"
 Else: strTemp = strTemp & Mid(strTest, kount, 1)
End If
Next kount
stripIllegalChars = IIf(Len(strTemp) < 1, "Missing_Subject" & Int(Rnd(1) * 1000), strTemp)
End Function
' ───────

Leave a Reply

Your email address will not be published. Required fields are marked *