Xbasic
VAL Function
Syntax
Numeric_Value as N = VAL(C character)
Arguments
- character
A character string containing number characters
Description
Converts a character string to a numeric value.
Discussion
VAL() converts a Character_String to a numeric value. If the Character_String contains leading non-numeric characters, then a value of 0 is returned.
Example
val("12345") -> 12345 val("abc234") -> 0 val("1234abc234") -> 1234
Assume that you have an inventory table with a PARTNO field that contains values such as "PH12" and "AK7864", etc. The field's first two characters contain a character code, and the remaining characters (up to four) are a number. To find all the parts with numbers between 20 and 4000, regardless of the code in the first two character positions, use the following filter expression:
val( substr( PARTNO, 3, 4)) > = 20 .AND. val( substr( PARTNO, 3, 4)) < = 4000
See Also