ToDecimal
Description:
Convert numeric characters in a string to a decimal number.
Format:
ToDecimal (string Text)
|
Parameters: |
String |
Text |
Text that contains a number. |
|
Return Value: |
Decimal |
Number |
The converted number |
Usage:
Use this function to convert a String that contains a number to a Decimal number. Data from Documents is all in a Text (String) format. Math cannot be performed on Text. This function will convert a string that happens to contain numeric characters into a number that can be manipulated with mathematical functions. All the characters in the string must consist of a valid number. If the string does not contain a valid number, the function returns 0. Valid numbers consist of a an optional sign (+ or -), the numbers 0 – 9, and a maximum of one period (.) anywhere in the number characters. Examples of valid strings are: '123.45', '-123.45', '+123.45', '-.501', '123'. Examples of invalid strings are: '123.45-', '1.2.3', '12345 ABC', '123 456'
Example 1:
Convert a string containing '12.5' into a Decimal variable and then multiply it by 2.
String strData
Decimal decResult
// Set string data
strData = '12.5'
// Convert the string and multiply by 2
decResult = ToDecimal (strData) * 2