Telephone numbers

  • Thread starter Thread starter Graham Richardson
  • Start date Start date
G

Graham Richardson

I know that this has probably been asked before but how
would I remove spaces in the middle of a series of numbers
as well as anyother none numeric character.

Thanks
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Here's what I use:

Public Function NumbersOnly(ByVal varNumber) As Variant
' Purpose:
' Clean up the number - get rid of punctuation.
' In:
' varNumber The number may/may not have punctuation in it.
' Out:
' Variant The original string w/o punctuation.
' Created:
' mgf 20apr2003
' Modified:
'

' Get rid of any non-numeric characters in the string
Dim i As Integer
Dim strChar As String
Dim strTemp As String

If IsNull(varNumber) Then Exit Function

For i = 1 To Len(varNumber)
strChar = Mid$(varNumber, i, 1)
If IsNumeric(strChar) Then strTemp = strTemp & strChar
Next i

NumbersOnly = strTemp

End Function

=====

I use it in a query like this:

SELECT ClientName, NumbersOnly(PhoneNumber) As PhNumber
FROM ... etc. ...

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQRPNaYechKqOuFEgEQIo6ACg/kFOTH62teRVDzy2jHVzGq2hA/4AoMy4
lGGUIwa94GMiAexP0jP8gWb7
=mN3H
-----END PGP SIGNATURE-----
 
Back
Top