Extract numbers from an alpha numeric string

From CodeCodex

Revision as of 19:05, 20 July 2006 by 206.160.140.2 (Talk)

Implementations

Visual Basic

Function OnlyNumbers(ByVal Str As String) As Long
  Dim i As Long, k As Long, j As Long
  For i = 0 To Len(Str)
    k = Mid(Str, i + 1, 1)
    If Not k >= 0 Or k <= 9 Then
      j = j + k
    End If
  Next
  OnlyNumbers= j
End Function