Converts a number in character format to numeric format.
String.ToNumeric()
Where:
String
Is an attribute or variable based on the Character/VarChar/LongVarChar data type.
Type Returned:
Numeric N(18.2)
Data Types: Character, VarChar, LongVarChar
Generators:
.NET,
.NET Framework, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)
This method converts the numbers of a character expression to a numeric type. It processes the numbers in the character expression from left to right until a non-numeric character is encountered. If the first character of the character expression is not a number, the result of ToNumeric method will be 0.
&AcceptTxt = '-123.35'
&Nbr = &AcceptTxt.ToNumeric() //&Nbr = -123
&AcceptTxt = 'ABC'(*)
&Nbr = &AcceptTxt.ToNumeric() //&Nbr = 0
&AcceptTxt = '12A' (*)
&Nbr = &AcceptTxt.ToNumeric() //&Nbr = 12
Note: Converting alphanumerics to numerics (*) is not supported when the method is evaluated in the DBMS (see Server Side Functions/Methods or SAC 42709).
Val function
Str function
ToString method