22 | 06 | 2017

Remove Special Characters

Function below removes special characterslike "!@#$%^&*(){}[]""_+<>?/ as defined by the user.

    1 Function RemoveSpecialCharacters(ByVal Str As String)

    2 

    3     'Define the special characters you wish to remove

    4     Dim illegalChars As Char() = ("!@#$%^&*(){}[]""_+<>?/").ToCharArray

    5     Dim sb As New System.Text.StringBuilder

    6 

    7     For Each ch As Char In Str

    8         If Array.IndexOf(illegalChars, ch) = -1 Then

    9             sb.Append(ch)

   10         End If

   11     Next

   12 

   13     RemoveSpecialCharacters = sb.ToString()

   14 End Function

Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2284708
Latest Articles