G
Guest
i want to remove special character like &,.,( ),space,from a string
Allen Browne said:Paste the function below into a standard module, and save it.
You can then call the function to strip whichever characters you wish from a
string, e.g.:
=Strip([MyField], "&., ()")
Function Strip(vPhrase, sBadChars As String)
' Purpose: remove any of the characters in sBadChars from vPhrase
Dim sPhrase As String
Dim i As Integer
If IsNull(vPhrase) Or IsEmpty(vPhrase) Or Len(sBadChars) = 0 Then
Strip = vPhrase
Else
sPhrase = vPhrase
i = 1
Do Until i > Len(sPhrase)
Do Until InStr(sBadChars, Mid$(sPhrase, i, 1)) = 0 Or i >
Len(sPhrase)
sPhrase = Left$(sPhrase, i - 1) & Mid$(sPhrase, i + 1)
Loop
i = i + 1
Loop
Strip = sPhrase
End If
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
prad said:i want to remove special character like &,.,( ),space,from a string
prad said:thanks Allen Browne its working now.now can u give me code for how to
add controls into report programmatically using a template
Allen Browne said:Paste the function below into a standard module, and save it.
You can then call the function to strip whichever characters you
wish from a string, e.g.:
=Strip([MyField], "&., ()")
Function Strip(vPhrase, sBadChars As String)
' Purpose: remove any of the characters in sBadChars from vPhrase
Dim sPhrase As String
Dim i As Integer
If IsNull(vPhrase) Or IsEmpty(vPhrase) Or Len(sBadChars) = 0 Then
Strip = vPhrase
Else
sPhrase = vPhrase
i = 1
Do Until i > Len(sPhrase)
Do Until InStr(sBadChars, Mid$(sPhrase, i, 1)) = 0 Or i >
Len(sPhrase)
sPhrase = Left$(sPhrase, i - 1) & Mid$(sPhrase, i +
1) Loop
i = i + 1
Loop
Strip = sPhrase
End If
End Function
prad said:thanks Allen Browne its working now.now can u give me code for how to add
controls into report programmatically using a template
Allen Browne said:Paste the function below into a standard module, and save it.
You can then call the function to strip whichever characters you wish
from a
string, e.g.:
=Strip([MyField], "&., ()")
Function Strip(vPhrase, sBadChars As String)
' Purpose: remove any of the characters in sBadChars from vPhrase
Dim sPhrase As String
Dim i As Integer
If IsNull(vPhrase) Or IsEmpty(vPhrase) Or Len(sBadChars) = 0 Then
Strip = vPhrase
Else
sPhrase = vPhrase
i = 1
Do Until i > Len(sPhrase)
Do Until InStr(sBadChars, Mid$(sPhrase, i, 1)) = 0 Or i >
Len(sPhrase)
sPhrase = Left$(sPhrase, i - 1) & Mid$(sPhrase, i + 1)
Loop
i = i + 1
Loop
Strip = sPhrase
End If
End Function
prad said:i want to remove special character like &,.,( ),space,from a string