MS Access: Extract only numeric values from alphanumeric string/text

I have posted many parsing functions in my blog. Like remove special characters from a string, Extract only alphabets from a string, Extract only special charcters from a string etc. Here is a function to extract only numeric values in a given string/text.
Public Function udfExtractNumeric(strInput) As String
Dim strResult As String, strCh As String
Dim i As Integer
If Not IsNull(strInput) Then
For i = 1 To Len(strInput)
strCh = Mid(strInput, i, 1)
Select Case strCh
Case "0" To "9"
strResult = strResult & strCh
Case Else
End Select
Next i
End If
udfExtractNumeric= strResult
End Function

Results

No comments:

Post a Comment