'---------------------------------------------------------------------------------------
' Procedure : fExtractStrt
' DateTime : 12/10/2004 22:47
' Author : mellon
' Purpose : Return the Numeric parts of the input string
' This ignores non numeric characters and returns only the
' numeric string in the order it was input.
'
' Sample call:
'
'Sub testForNumeric()
'
'Dim x As String: x = "123 4567 8966"
'Debug.Print fExtractStrt(x)
'''''gives result: 12345678966
'End Sub
'---------------------------------------------------------------------------------------
'Reviewed Dec 2004
Function fExtractStrt(strInString As String) As String
'JED Jan 2000
'This routine can take a combined Areacode and phone/fax number
' (234) 234-4567 in various formats
'and output 10 digits contiguous
'where left 3 is Area code
' right 7 is number
'
'
'It could be used on any string to remove " ",(,), or - characters
'
' chr 32 space
' chr 40 (
' chr 41 )
' chr 45 -
' chr 46 .
'************ Code Start **********
Dim lngLen As Long, strOut As String
Dim i As Long, strTmp As String
lngLen = Len(strInString)
strOut = ""
If lngLen = 0 Then GoTo NullWasSupplied_Exit
For i = 1 To lngLen
strTmp = Left$(strInString, 1)
strInString = Right$(strInString, lngLen - i)
If Asc(strTmp) = 32 Or _
Asc(strTmp) = 40 Or _
Asc(strTmp) = 41 Or _
Asc(strTmp) = 45 Or _
Asc(strTmp) = 46 Then
GoTo bypassOutput
Else
strOut = strOut & strTmp
End If
bypassOutput:
Next i
NullWasSupplied_Exit:
fExtractStrt = strOut
End Function