Val Function


Val Function

Class

Microsoft.VisualBasic.Conversion

Syntax

     Dim result As Double = Val(expression) 

or

     Dim result As Integer = Val(charExpression) 


expression (required; String or Object)

Any string representation of a number


charExpression (required; Char)

Any valid character

Description

The Val function converts a string or object representation of a number to the Double data type. A second variation converts a Char data type to its Integer equivalent.

Usage at a Glance

  • Only digits at the start of the string expression are examined for conversion; conversion stops at the first nonnumeric character. All whitespace is removed before conversion. An empty string converts to zero.

  • &O and &H (the octal and hexadecimal prefixes) are recognized by the Val function.

  • Currency symbols, such as $ and £, and delimiters, such as commas, are not recognized by the Val function.

  • The Val function only recognizes the period (.) as a decimal delimiter; regional settings are ignored.

  • The conversion functions, such as the CDbl function, consider regional settings.

See Also

CDbl Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net