UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetDigitsOnly    

Synopsis

Returns all the numeric portion of a string.

Related Functions: IsNumbersOnly, GetAlphaOnly and Strip Illegal Characters

CODE

' GetDigitsOnly
' http://www.utteraccess.com/wiki/index.php/GetDigitsOnly
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2011-04-05                    Returns all the digits within a string.
'
Public Function fnDigitsOnly(strInput As String) As String

Dim intLen As Integer
Dim intIndex As Integer
Dim strChar As String * 1
Dim strTemp As String

intLen = Len(strInput)
For intIndex = 1 To intLen
  strChar = Mid(strInput, intIndex, 1)
  If (strChar >= "0") And (strChar <= "9") Then
    strTemp = strTemp & strChar
  End If
Next intIndex

' Return
fnDigitsOnly = strTemp

End Function

Creative Commons License
GetDigitsOnly by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 7,128 times.  This page was last modified 09:08, 6 April 2011 by Jack Leach. Contributions by TheDBguy  Disclaimers