Replace all non numerics with blanks

R

raj

how can i replace all non nuerics with blanks

i have some phone numbers such as follows:

(111)111-1111
or
111-111-1111

or
(111)1111111

i want to get rid of all non numbers and just have
1111111111

thanks
 
K

Karl E. Peterson

raj said:
how can i replace all non nuerics with blanks

i have some phone numbers such as follows:

(111)111-1111
or
111-111-1111

or
(111)1111111

i want to get rid of all non numbers and just have
1111111111

That's a whole lot different from what most folks would consider "blanks" --
ie, space chars.

I'd just loop through it, concatenating numeric chars to a new string.

Public Function Crush(ByVal MyString As String) As String
Dim i As Long
Dim char As String
Dim retval As String

For i = 1 To Len(MyString)
char = Mid$(MyString, i, 1)
Select Case Asc(char)
Case 48 To 57
retval = retval & char
End Select
Next i
Crush = retval
End Function

Later... Karl
 

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

Top