Int64Static: ToString

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

Parameters

Value
[ByRef] Int64. The 64-bit integer to be converted to a string.
Format
[ByRef] Optional. String. A numeric format string.
Provider
[ByVal] Optional. IFormatProvider. An object that supplies culture-specific formatting information about this instance.

Return Values

String -  The string representation of the value of this instance as specified by Format and Provider.

Remarks

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.

Exceptions

Exception Condition
FormatExceptionFormat is invalid or not supported.

Examples

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

See Also

Project CorLib Overview

Class Int64Static Overview

IFormatProvider