CFLib.org – Common Function Library Project

Convert2Number(strVal)

Last updated November 15, 2002

author

Glenn Wilson

Version: 1 | Requires: CF5 | Library: MathLib

Description:
This function will take any string and strip out all characters that are not (-.0123456789) and will then determine it's numeric value.

Return Values:
Returns a number.

Example:

Convert2Number($3,456.78) will return the numeric value 3456.78

Parameters:

Name Description Required
strVal Value to convert. Yes

Full UDF Source:

/**
 * Converts any numeric string (even ones with currancy symbols to a number).
 * 
 * @param strVal 	 Value to convert. (Required)
 * @return Returns a number. 
 * @author Glenn Wilson (glenn.wilson@quotegen.com) 
 * @version 1, November 15, 2002 
 */
function Convert2Number(StrVal){
  var regStr = "[^/.0123456789-]";
  return Val(REReplace(StrVal,regStr,"","all"));
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson