For Answers, see/post comments

function in vb.net

Hi friends,

I've written a funciton to strip all special characters. But the space is not working.. help me. my coding is

Public Function strip(ByVal des As String)

Dim strorigFileName As String

Dim intCounter As Integer

Dim arrSpecialChar() As String = {".", ",", "<", ">", ":", "?", """", "/", "{", "[", "}", "]", "`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "=", "", " ", "\"}

strorigFileName = desintCounter = 0Do Until intCounter = 29

des = Replace(strorigFileName, arrSpecialChar(intCounter), "")

intCounter = intCounter + 1

strorigFileName = des

Loop

Return strorigFileName

End Function

1 comment:

Anonymous said...

Public Function strip(ByVal des As String)
Dim strorigFileName As String
Dim intCounter As Integer
Dim arrSpecialChar() As String = {".", ",", "<", ">", ":", "?", """", "/", "{", "[", "}", "]", "`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "=", "|", " ", "\"}
strorigFileName = des
intCounter = 0
Dim i As Integer
MsgBox("before " & des)
For i = 0 To arrSpecialChar.Length - 1

Do Until intCounter = 29
des = Replace(strorigFileName, arrSpecialChar(i), "")
intCounter = intCounter + 1
strorigFileName = des
Loop
intCounter = 0
Next
MsgBox("after " & des)
Return strorigFileName

End Function