|
|
|
|
|
- Conversion range
- Val and UNICODE
- Miscellaneous
Val (Function) In french: Val Returns the numeric value of a character string. This feature enables you to perform numeric calculations on strings. Val("143")
Val("1.67")
Val("ABC")
Val("3plus2")
Val("7,5")
Val("1D2")
Val("2.5e-2")
Syntax
<Result> = Val(<Initial string> [, <Base used>])
<Result>: Real or integer - Numeric value of the string.
- "inf" (for "infinite"), if the result exceeds the capabilities of a real. It is recommended to convert the value to a variable of type int.
- 0 if an error occurs.
<Initial string>: Character string or Buffer Character string to convert to a numeric value. For a real, the separator must be the dot ('.') and the prefixes for scientific notation can be 'E', 'e', 'D' or 'd'. If the separator is a comma, the numbers after the comma will be ignored.This parameter can also be a buffer. In this case, the buffer will be processed differently, according to the option selected in the "Unicode" tab of the configuration description: - if "Use ANSI strings at runtime" is selected, the buffer will be processed as an ANSI string.
- if "Use UNICODE strings at runtime" is selected, the buffer will be processed as an ANSI or Unicode string, depending on its content.
<Base used>: Character string or integer (optional) Base in which the number is represented. The possible values are as follows:- "d": base 10 (decimal),
- "x": base 16 (hexadecimal),
- "o": base 8 (octal),
- an integer between 2 and 36.
Base 10 is used by default. Remarks Conversion range Val converts a string to an integer if the value is between -9.223.372.036.854.775.808 and 9.223.372.036.854.775.807. Val and UNICODE The <Chaîne initiale> parameter can be in ANSI or Unicode format. Miscellaneous If a character of <Initial string> cannot be interpreted as a number, Val stops interpreting <Initial string> and returns the number corresponding to the characters already read. Reals can be converted from base 10 only. In other bases, all characters after "." (point) will be ignored.
Related Examples:
|
Unit examples (WINDEV): The Val function
[ + ] Using the WLanguage "Val" function with different databases. For example, it allows you to retrieve the decimal value of a string in Hexadecimal format.
|
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|