This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.
This version is copyright and may only be used for local testing purposes. It may not be distributed.
Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.
Description
Return the numeric equivalent of a string argument.
Syntax
n = Val(StringExpression [, nDecimals])
Returns
Number
Parameters
Name |
Type |
Optional |
Meaning |
StringExpression |
String |
No |
String expression to be converted into a number |
nDecimals |
Numeric |
yes |
Number of decimal places to return in the rounded number. If this optional parameter will be specified, returned value will be rounded the number of decimal places indicated. |
Remarks
VAL can also be used to convert string arguments that are in the form of Hexadecimal, Binary and Octal numbers.
Hexadecimal values should be prefixed with "&H"
Binary values should be prefixed with "&B".
Octal values may be prefixed "&O", "&Q" or just "&".
If the StringExpression contains a leading zero, the result is returned as an unsigned value, otherwise, a signed value is returned.
Examples:
n = VAL("&HF5F3") ' Hex, returns -2573 (signed)
n = VAL("&H0F5F3") ' Hex, returns 62963 (unsigned)
n = VAL("&B0100101101") ' Binary, returns 301 (unsigned)
n = VAL("&O4574514") ' Octal, returns 1243468 (signed)
Restrictions
VAL stops analyzing StringExpression when non-numeric characters are encountered.
When dealing with Hexadecimal, Binary, and Octal number systems, the period character is classified as non-numeric.
VAL accepts the period character as a decimal place for all decimal number system values.
See also
Examples