Converts the value of a string to a decimal.
Dec ( string )
Argument |
Description |
---|---|
string |
The string you want returned as a decimal |
Alternatively, you can append the uppercase or lowercase letter
D to a value to identify it as a decimal constant. For example, 2.0d
and 123.456789012345678901D
are
treated as decimals.
Decimal. Returns the contents of string as a decimal if it succeeds and 0 if string is not a number.
The decimal datatype supports up to 28 digits.
The Find statement below searches for the first row in dw_customer whose id column contains the decimal value 10030434463453863. The d appended to the value prevents it from being converted to a double:
long ll_found ll_found = dw_customer.Find ("id = 10030434463453863d", 1, dw_customer.RowCount())
The next expression returns the string 24.3 as a decimal datatype:
Dec("24.3")
This expression for a computed field returns “Not a valid score” if the string in the score column does not contain a number. The expression checks whether the Dec function returns 0, which means it failed to convert the value:
If ( Dec(score) <> 0, score, "Not a valid score")
This expression returns 0:
Dec("3ABC") // 3ABC is not a number
This validation rule checks that the value in the column the user entered is greater than 1999.99:
Dec(GetText()) > 1999.99
This validation rule for the column named score insures that score contains a string:
Dec(score) <> 0