0
我有一个代码来检查字符串中是否有任何特殊字符。如果它检测到字符,它将只删除字符并继续检查。或者,如果您有更简单的方法,请协助我。谢谢删除字符串中的特定字符
Public Function IsThereAnySpecialCharacter(ByVal str As String) As Integer
Dim illegalChars As Char() = "~`|@#$^*{}'[]""_<>\".ToCharArray()
Dim count As Integer
Try
count = 0
For Each ch As Char In str ' to check whether special character exist in a string
If Not Array.IndexOf(illegalChars, ch) = -1 Then
xxxxxxxxxxxxxxxxx ' I want to remove the chars here
count = count + 1
End If
Next
Return count
Catch ex As Exception
strErrMsg = "Oops! Something is wrong with verify special characters at IsThereAnySpecialCharacter"
MessageBox.Show(strErrMsg & vbCrLf & "Err: " & ex.Message)
End Try
End Function
Yes..that工作。谢谢 – Luiey