Trimming a telephone number....Or replacing

B

buckpeace

I need to either trim or replace this number: (386)851-0090
to look like: 3868510090 (no dashes or ())

Any help will be appreciated.
 
K

kingston via AccessMonster.com

If the format is consistent, then

Mid([original number],2,3) & Mid([original number],6,3) & Mid([original
number],10,4)
 
M

Marshall Barton

buckpeace said:
I need to either trim or replace this number: (386)851-0090
to look like: 3868510090 (no dashes or ())


If that the only cases you have to deal with:

Replace(Replace(Replace(phone, "(", ""), ")", ""), "-", "")

If it gets much more complicated than that, you should
probably create a function to keep only digits:

Public Function ExtractDigits(s)
Dim k As Integer
If IsNull(s) Then Exit Function
For k = 1 to Len(s)
If Mid(s, k, 1) Like "#" Then
ExtractDigits = ExtractDigits & Mid(s, k, 1)
End If
Next k
End Function
 
B

Bikini Browser

Gosh..

It is so easy... No programming needed...

Just use search and replace from the Edit menu..

Search for ( and replace it with nothing
Search for ) and replace it with nothing
Search for - and replace it with nothing

Easy.

You can also search for spaces and replace it with nothing

Dale
 
Top