Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Strings.FormatNumber Method

Returns an expression formatted as a number.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public static string FormatNumber(
	Object Expression,
	int NumDigitsAfterDecimal,
	TriState IncludeLeadingDigit,
	TriState UseParensForNegativeNumbers,
	TriState GroupDigits
)

Parameters

Expression
Type: System.Object
Required. Expression to be formatted.
NumDigitsAfterDecimal
Type: System.Int32
Optional. Numeric value indicating how many places are displayed to the right of the decimal. The default value is –1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit
Type: Microsoft.VisualBasic.TriState
Optional. TriState constant that indicates whether a leading 0 is displayed for fractional values. See "Settings" for values.
UseParensForNegativeNumbers
Type: Microsoft.VisualBasic.TriState
Optional. TriState constant that indicates whether to place negative values within parentheses. See "Settings" for values.
GroupDigits
Type: Microsoft.VisualBasic.TriState
Optional. TriState constant that indicates whether or not numbers are grouped using the group delimiter specified in the locale settings. See "Settings" for values.

Return Value

Type: System.String
Returns an expression formatted as a number.

When one or more optional arguments are omitted the values for omitted arguments are provided by the locale settings.

NoteNote:

All settings information comes from the locale of the application. By default, that will be the locale set in the control panel. However, it may be changed programmatically by using the .NET Framework.

The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings.

Constant

Description

TriState.True

True

TriState.False

False

TriState.UseDefault

The computer's regional settings

This example demonstrates the FormatNumber function.


Dim TestNumber As Integer = 45600
' Returns "45,600.00".
Dim TestString As String = FormatNumber(TestNumber, 2, , , TriState.True)


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.