CodeItBetter Programming Another VB Programming Blog

How to Extract only numbers from a given string

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'String Manipulation - How to Extract only numbers from a given string
Public Function ExtractOnlyNumbers(ByVal Str As String) As String
    Dim I As Long, J As Long, K As String
    Dim strText As String
    For I = 1 To Len(Str)
        K = Mid$(Str, I, 1)
        If IsNumeric(K) Then
            strText = strText & K
        End If
    Next
    ExtractOnlyNumbers = strText
End Function
'Call this function as:
'Debug.Print ExtractOnlyNumbers("test849tkk494")
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.