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

Remove 0 and space from Telephone number

Status
Not open for further replies.

slickp

Technical User
Feb 15, 2006
35
GB
I'm creating a report in Crystal and I would like to change the telephone number so that the 0 at the front of the number is removed, plus any non number characters are removed, i.e (, *, etc.

The format i've got at the moment is random:

01234 358824
0171-254-2545

I would like it so that the numbers above could be changed to:

1234358824
1712542545

Is this possible?
 
Two different problems: you want to remove 0 at the start and also special characters anywhere in the number.

In the UK, leading zeros in phone numbers are necessary and cannot be skipped. But if you're sure you want to get rid of them, try
Code:
If Left({your.telephone}, 1) = "0" 
then Right({your.telephone}, length({your.telephone})-1)
else {your.telephone}
That's to say, if the first character on the left is 0, take everything from the right for one less than the actual length of the data.

For the rest, you can replace characters, a formula field nesting commands within commands; e.g.
Code:
Replace(Replace("*", "", {your.telephone}), "-", ""))
You can do this a number of times, within a formula field or by using the formula field as input to another formula field.

Best to start with one replace, get it working and then improve it.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top