Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StripString Double Quotes and Carriage Return

Status
Not open for further replies.

mgifford

Programmer
Jun 3, 2004
30
US
I need to strip out double quotes and carriage returns in my text fields on a form. Here's what I have for the function to replace " " with ' ':

'---------------------------
Function StripString( sPassed )
Dim sReturn, i, iLen, sChar, sLookFor

iLen = Len(sPassed)
sLookFor = Chr(34)

For i = 1 To iLen
sChar = Mid(sPassed,i,1)
If sChar = sLookFor Then
sReturn = sReturn & "'"
Else
sReturn = sReturn & sChar
End If
Next

StripString = sReturn

End Function

Is this right and how do I do the Chr(13) for the carriage return?

As always, I am grateful for all the help!
 
And what about the Replace function ?
newString = Replace(oldString, Chr(34), "'")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello mgifford,

Also to take out chr(13) it is this.
[tt]newString = Replace(newString, chr(13), "") [/tt]
But not sure if you want to put anything at its places.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top