判断字符串中是否含有非法字符函数
'================================================
'函数名:IsValidStr
'作 用:判断字符串中是否含有非法字符
'参 数:str ----原字符串
'返回值:False‚True -----布尔值
'================================================
Public Function IsValidStr(ByVal str)
IsValidStr = False
On Error Resume Next
If IsNull(str) Then Exit Function
If Trim(str) = Empty Then Exit Function
Dim ForbidStr‚ i
ForbidStr = "and|chr|:|=|%|&|$|#|@|+|-|*|/|\|<|>|;|‚|^|" & Chr(32) & "|" & Chr(34) & "|" & Chr(39) & "|" & Chr(9)
ForbidStr = Split(ForbidStr‚ "|")
For i = 0 To UBound(ForbidStr)
If InStr(1‚str‚ ForbidStr(i)‚1) > 0 Then
IsValidStr = False
Exit Function
End If
Next
IsValidStr = True
End Function