Filtering text out of a string

John liem

Registered User.
Local time
Today, 23:23
Joined
Jul 15, 2002
Messages
112
I want to filter out the numbers in a text string in a query, how can I do this?
Example: 12a34d36wk11 to adwk
John.
 
Put this in a module:

Code:
Public Function RemoveNumbers(strTemp As String) As String
    Dim intCounter As Integer
    Dim intAscii As Integer
    For intCounter = 1 To Len(strTemp)
        intAscii = Asc(Mid(strTemp, intCounter, 1))
        If intAscii < 48 Or intAscii > 57 Then
            RemoveNumbers = RemoveNumbers & Chr(intAscii)
        End If
    Next intCounter
End Function


In the query, create a calculated field:

NewField: RemoveNumbers([OldField])
 
Mile-O-Phile said:
Put this in a module:

Code:
Public Function RemoveNumbers(strTemp As String) As String
    Dim intCounter As Integer
    Dim intAscii As Integer
    For intCounter = 1 To Len(strTemp)
        intAscii = Asc(Mid(strTemp, intCounter, 1))
        If intAscii < 48 Or intAscii > 57 Then
            RemoveNumbers = RemoveNumbers & Chr(intAscii)
        End If
    Next intCounter
End Function


In the query, create a calculated field:

NewField: RemoveNumbers([OldField])


Thanks Phile .....
 

Users who are viewing this thread

Back
Top Bottom