Int64Static: TryParseEx

TryParseEx

Converts the string representation of a number in a specified style and culture-specific format to its 64-bit signed integer equivalent.



 Public Function TryParseEx(
	  ByRef s As String,
	  ByVal Style As NumberStyles,
	  ByVal Provider As IFormatProvider,
	  ByRef Result As Int64 ) As Boolean

Parameters

s
[ByRef] String. A string containing a number to convert.
Style
[ByVal] NumberStyles. A bitwise combination of enumeration values that indicates the style elements that can be present in s. A typical value to specify is Integer.
Provider
[ByVal] IFormatProvider. An IFormatProvider that supplies culture-specific formatting information about s.
Result
[ByRef] Int64. When this method returns, contains the 64-bit signed integer value equivalent of the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is empty, is not in a format compliant withstyle, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized; any value originally supplied in Result will be overwritten.

Return Values

Boolean -  True if s was converted successfully; otherwise, False.

Remarks

The Style parameter defines the style elements (such as white space or the positive sign) that are allowed in the s parameter for the parse operation to succeed. It must be a combination of bit flags from the NumberStyles enumeration. Depending on the value of Style, the s parameter may include the following elements:

[ws][$][sign][digits,]digits[.fractional_digits][e[sign]exponential_digits][ws]

Or, if style includes AllowHexSpecifier:

[ws]hexdigits[ws]

Elements in square brackets ([ and ]) are optional. The following table describes each element.

Element Description
wsOptional white space. White space can appear at the beginning of s if Style includes the NumberStyles.AllowLeadingWhite flag, and it can appear at the end of s if Style includes the NumberStyles.AllowTrailingWhite flag.
$A culture-specific currency symbol. Its position in the string is defined by the NumberFormatInfo.CurrencyPositivePattern property of the NumberFormatInfo object returned by the GetFormat method of the Provider parameter. The currency symbol can appear in s if style includes the NumberStyles.AllowCurrencySymbol flag.
digits
fractional_digits
expontial_digits
A sequence of digits from 0 through 9.
,A culture-specific thousands separator symbol. The thousands separator of the culture specified by Provider can appear in s if Style includes the NumberStyles.AllowThousands flag.
. A culture-specific decimal point symbol. The decimal point symbol of the culture specified by Provider can appear in s if style includes the NumberStyles.AllowDecimalPoint flag.
Only the digit 0 can appear as a fractional digit for the parse operation to succeed; if fractional_digits includes any other digit, an OverflowException is thrown.
eThe e' or 'E' character, which indicates that the value is represented in exponential notation. The s parameter can represent a number in exponential notation if Style includes the NumberStyles.AllowExponent flag.
hexdigitsA sequence of hexadecimal digits from 0 through f, or 0 through F.

A string expression beginning with "0x" or "&h" will be parsed as a hex value.

See Also

Project CorLib Overview

Class Int64Static Overview

Parse

ParseEx

TryParse