In Access, the Val function returns a variant indicating the sign of a number.
The syntax for the Val function is:
Val( string )
The required string argument is any valid string expression. It is a sequence of characters that can be interpreted as a numeric value. Val stops reading the string at the first character that it cannot recognize as part of a number. Val also strips blanks, tabs, and linefeeds from the argument string. Symbols and characters often considered part of a numeric value, such as the dollar sign and commas, are not recognized by Val as numeric. The Val function always returns a Double. If the result of the Val function is assigned to a variable, the Double returned by Val is forced into the datatype of the variable.
Example
|
VBA Code
|
This example uses the Val function to return the numbers contained in a string. Now the MyNumber variable would contain the value 2457.
SQL query
You can also use the Val function in a query.
|