Remove non-numerics from a field?

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

Guest

I need a fast function to remove all non-numeric characters from a field,
what is the best way to do it?
It must remove any embedded spaces, e.g.
AB12 3C must become 123
 
Untested air-code:

Function RemoveNonNumeric(InputString) As String
Dim lngLoop As Long
Dim strCurrChar As String
Dim strOutput As String

For lngLoop = 1 To Len(InputString)
strCurrChar = Mid$(InputString, lngLoop, 1)
If strCurrChar >= "0" And strCurrChar <= "9" Then
strOutput = strOutput & strCurrChar
End If
Next lngLoop

RemoveNonNumeric = strOutput

End Function
 
Back
Top