Filtering out Numbers only

AlanW

Registered User.
Local time
Today, 19:07
Joined
Aug 11, 2001
Messages
25
I have a Field that contains both numbers and text. I would like to filter out just the numbers. What do I need to put in the criteria of the query?

Thanks
 
To leave just the numeric portion of a strong, you could try this:


Function removeit(thestuff As String) As String
'*******************************************
'Name: removeit (Function)
'Purpose: Remove all non-numeric characters from a string
'*******************************************
Dim strhold As String, intLen As Integer, n As Integer
strhold = RTrim(thestuff)
intLen = Len(strhold)
strhold = ""
For n = 1 To intLen
strhold = strhold & IIf(IsNumeric(Mid(thestuff, n, 1)), Mid(thestuff, n, 1), "")
Next n
removeit = strhold
End Function

Conversely, to remove the numeric, leaving just the alpha, change this line:

IIf(IsNumeric(Mid(thestuff, n, 1)), Mid(thestuff, n, 1), "")

to this

IIf(Not IsNumeric(Mid(thestuff, n, 1)), Mid(thestuff, n, 1), "")
 

Users who are viewing this thread

Back
Top Bottom