Int64Static: TryParse |
Converts the string representation of a number to its 64-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.
Public Function TryParse( ByRef s As String, ByRef Result As Int64 ) As Boolean
The TryParse method is like the Parse method, except the TryParse method does not throw an exception if the conversion fails. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.
The s parameter contains a number of the form:
[ws][sign]digits[ws]
Elements in square brackets ([ and ]) are optional. The following table describes each element.
Element | Description |
---|---|
ws | Optional white space. |
sign | An optional sign. |
digits | A sequence of digits ranging from 0 to 9. |
The s parameter is interpreted using the NumberStyles.Integer style. In addition to decimal digits, only leading and trailing spaces together with a leading sign are allowed. To explicitly define the style elements that can be present in s, use Int64.ParseEx(String, NumberStyles) or the Int64.Parse(String, NumberStyles, IFormatProvider) method.
A string expression beginning with "0x" or "&h" will be parsed as a hex value.