


Val
Purpose
Returns the numeric value of a string of characters.
Arguments
Val( stringexpression )
Notes
The argument stringexpression 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. For
example, the following returns the value 1615198:
Val(" 1615 198th Street N.E.")
Symbols and characters often considered part of a numeric value, such as the
dollar sign and commas, are not recognized by Val as numeric. Val does recognize the radix prefixes &O (for octal) and &H (for hexadecimal). In the code below, Val returns the decimal value -1 for the hexadecimal value shown:
Val("&HFFFF")
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.
Tip If the string expression you want to convert to numbers contains only
numbers, consider using one of the numeric data type conversion functions (CCur,
CDbl, CInt, CLng, CSng, or CVar) to perform the conversion. To convert a numeric
value to a String or Variant, you can use the Format$, CStr, or CVar function.