'********************************************************************

'*

'* Function CNum

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2008-04-17

'* Modified: 2008-04-17

'*

'* Purpose: Convert a text String to a number.  Remove any non-number

'*            text first.  A period "." is always considered a decimal.

'*

'* Input:   strAny      A string containing numbers.

'*

'* Output: Returns the remaining numbers in the string as a Double

'*           Precision Data Type.

'*

'********************************************************************

Function CNum(ByVal strAny)

  'Version: 1.0 2008-04-17

  Dim strNew, x, intAsc

 

  For x = 1 to Len(strAny)

    Select Case Asc(Mid(strAny, x, 1))

    Case 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57

      'Below are the corresponding ASCII characters.

      '   .,  0,  1,  2,  3,  4,  5,  6,  7,  8, 9

      strNew = strNew & Mid(strAny, x, 1)

    End Select 'Asc(Mid(strNew, x, 1))

  Next 'x

 

  CNum = CDbl(strNew)

End Function 'CNum

Article ID: 374, Created On: 9/25/2011, Modified: 9/25/2011