Int64Static: ToString |
Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
Public Function ToString( ByRef Value As Int64, Optional ByRef Format As String, Optional ByVal Provider As IFormatProvider ) As String
The Format parameter can be either a standard or a custom numeric format string. All standard numeric format strings other than "R" (or "r") are supported, as are all custom numeric format characters. If Format is not provided or an empty string (""), the return value for this instance is formatted with the general numeric format specifier ("G").
The Provider parameter is an object that implements the IFormatProvider interface. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific information about the format of the string that is returned by this method. The object that implements IFormatProvider can be any of the following:
If Provider is Nothing or a NumberFormatInfo object cannot be obtained from provider, the return value for this instance is formatted with the NumberFormatInfo for the current culture.
Exception | Condition |
---|---|
FormatException | Format is invalid or not supported. |
The following example displays an Int64 value using the default ToString() method. It also displays the string representations of the Int64 value that results from using a number of standard format specifiers. The examples are displayed using the formatting conventions of the en-US culture.
Public Sub Main() Dim Value As Int64 Value = CInt64(-16325091) ' Display value with default ToString method. Debug.Print Int64.ToString(Value) '' Displays -16325091 ' Display value using some standard format specifiers. Debug.Print Int64.ToString(Value, "G") '' Displays -16325091 Debug.Print Int64.ToString(Value, "C") '' Displays ($16,325,091.00) Debug.Print Int64.ToString(Value, "D") '' Displays -16325091 Debug.Print Int64.ToString(Value, "F") '' Displays -16325091.00 Debug.Print Int64.ToString(Value, "N") '' Displays -16,325,091.00 Debug.Print Int64.ToString(Value, "X") '' Displays FFFFFFFFFF06E61D End Sub