Val Function
Returns the numbers contained in a string as a numeric value of appropriate type.
Syntax
Val(string)
The required string argument is any valid string expression.
Remarks
The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes
|
|
The following returns the value 1615198:
|
In the code below, Val returns the decimal value -1 for the hexadecimal value shown:
|
Note
|
|---|
| The Val function recognizes only the period (.) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl instead to convert a string to a number. |
Example
This example uses the Val function to return the numbers contained in a string.
|
Note