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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Special Characters Except Spaces

Status
Not open for further replies.

FireGeek21

Technical User
Dec 12, 2007
218
0
0
US
HI!

I need to remove all special characters from a field except spaces. I found the following code here on Tek-Tips however it is also removing spaces too. Now my an address such as 1234 O'Mally Street appears 1234OMallyStreet and I need 1234 OMally Street. I know the ascii character for space is 32 but it isn't in the code. Help! THANKS!

Code:
whileprintingrecords;
Stringvar MyOutput:="";
Stringvar MyInput:= {EMPLOYEE.ADDR1};
numbervar Counter;
For Counter := 1 to len(trim(MyInput)) do(
if asc(mid(MyInput,Counter,1)) in [65 to 90]
or
   asc(mid(MyInput,Counter,1)) in [48 to 57]
or
   asc(mid(MyInput,Counter,1)) in [97 to 122]
then
MyOutput:=MyOutput+mid(MyInput,Counter,1)
);
MyOutput

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Duh! Figured it out. Added Chr(32) to the character code string. I guess when I first got this code, I read it as if these were the special characters it was removing, not all the characters that were ok to keep!

FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top