value function
DESCRIPTION
YYYYYYYYYYYYYYTRANSCRIPT
-
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 anumber. Symbols and characters that are often considered parts of numeric values, such as dollarsigns and commas, are not recognized. However, the function recognizes the radix prefixes &O (foroctal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from theargument.
The following returns the value 1615198:
Val(" 1615 198th Street N.E.")
In the code below, Val returns the decimal value -1 for the hexadecimal value shown:
Val("&HFFFF")
NoteThe Val function recognizes only the period (.) as a valid decimal separator. Whendifferent decimal separators are used, as in international applications, use CDbl instead toconvert a string to a number.
Page 1 of 1Val Function
2/24/2015mk:@MSITStore:C:\SOFT\VB\MSDN_L~1\MSDN\vbenlr98.chm::/html/vafctVal.htm