ValDec Function

   
ValDec Function

Class

Microsoft.VisualBasic.Conversion

Syntax

 ValDec(   expression   ) 
expression (required; String or Char)

Any string representation of a number

Return Value

A Decimal able to hold the number contained in expression

Description

Converts a string representation of a number into a Decimal

Rules at a Glance

  • The ValDec function starts reading the string with the leftmost character and stops at the first character that it does not recognize as being part of a valid number. For example, the statement:

     iNumber = ValDec("1A1") 

    returns 1.

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

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

  • The ValDec function only recognizes the period (.) as a decimal delimiter .

  • Prior to processing expression , ValDec removes spaces, tabs, and line-feed characters .

Programming Tips and Gotchas

If you are developing an international application, you should use the CDec function to convert strings to numbers, since CDec can recognize all decimal separators.

VB.NET/VB 6 Differences

The ValDec function is new to VB.NET.

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

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