Trimming a telephone number....Or replacing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Any help will be appreciated.
 
If the format is consistent, then

Mid([original number],2,3) & Mid([original number],6,3) & Mid([original
number],10,4)
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top