Strings.FormatNumber(Object, Int32, TriState, TriState, TriState) Metoda
Definice
Vrátí výraz formátovaný jako číslo.Returns an expression formatted as a number.
public static string FormatNumber (object? Expression, int NumDigitsAfterDecimal = -1, Microsoft.VisualBasic.TriState IncludeLeadingDigit = Microsoft.VisualBasic.TriState.UseDefault, Microsoft.VisualBasic.TriState UseParensForNegativeNumbers = Microsoft.VisualBasic.TriState.UseDefault, Microsoft.VisualBasic.TriState GroupDigits = Microsoft.VisualBasic.TriState.UseDefault);
public static string FormatNumber (object Expression, int NumDigitsAfterDecimal = -1, Microsoft.VisualBasic.TriState IncludeLeadingDigit = Microsoft.VisualBasic.TriState.UseDefault, Microsoft.VisualBasic.TriState UseParensForNegativeNumbers = Microsoft.VisualBasic.TriState.UseDefault, Microsoft.VisualBasic.TriState GroupDigits = Microsoft.VisualBasic.TriState.UseDefault);
static member FormatNumber : obj * int * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState -> string
Public Function FormatNumber (Expression As Object, Optional NumDigitsAfterDecimal As Integer = -1, Optional IncludeLeadingDigit As TriState = Microsoft.VisualBasic.TriState.UseDefault, Optional UseParensForNegativeNumbers As TriState = Microsoft.VisualBasic.TriState.UseDefault, Optional GroupDigits As TriState = Microsoft.VisualBasic.TriState.UseDefault) As String
Parametry
- Expression
- Object
Povinná hodnota.Required. Výraz, který má být formátován.Expression to be formatted.
- NumDigitsAfterDecimal
- Int32
Nepovinný parametr.Optional. Číselná hodnota označující, kolik míst se zobrazuje napravo od desetinné čárky.Numeric value indicating how many places are displayed to the right of the decimal. Výchozí hodnota je-1, což znamená, že se používají místní nastavení počítače.The default value is -1, which indicates that the computer's regional settings are used.
- IncludeLeadingDigit
- TriState
Nepovinný parametr.Optional. TriState konstanta, která označuje, zda je pro zlomkové hodnoty zobrazená úvodní hodnota 0.TriState constant that indicates whether a leading 0 is displayed for fractional values. Hodnoty naleznete v části „Nastavení“.See "Settings" for values.
- UseParensForNegativeNumbers
- TriState
Nepovinný parametr.Optional. TriState konstanta, která označuje, zda se mají v závorkách umístit záporné hodnoty.TriState constant that indicates whether to place negative values within parentheses. Hodnoty naleznete v části „Nastavení“.See "Settings" for values.
- GroupDigits
- TriState
Nepovinný parametr.Optional. TriState konstanta, která označuje, zda jsou čísla seskupena pomocí oddělovače skupiny zadaného v nastavení národního prostředí.TriState constant that indicates whether or not numbers are grouped using the group delimiter specified in the locale settings. Hodnoty naleznete v části „Nastavení“.See "Settings" for values.
Návraty
Výraz formátovaný jako číslo.An expression formatted as a number.
Výjimky
Typ není numerický.Type is not numeric.
Příklady
Tento příklad ukazuje FormatNumber funkci.This example demonstrates the FormatNumber function.
Dim testNumber As Integer = 45600
' Returns "45,600.00".
Dim testString As String = FormatNumber(testNumber, 2, , , TriState.True)
Poznámky
Pokud jsou vynechány některé volitelné argumenty, jsou hodnoty pro vynechané argumenty poskytovány nastavením národního prostředí.When one or more optional arguments are omitted the values for omitted arguments are provided by the locale settings.
Poznámka
Veškeré informace o nastavení přicházejí z národního prostředí aplikace.All settings information comes from the locale of the application. Ve výchozím nastavení se jedná o sadu národního prostředí v Ovládacích panelech.By default, that will be the locale set in the control panel. Dá se ale změnit programově pomocí .NET Framework.However, it may be changed programmatically by using the .NET Framework.
IncludeLeadingDigitArgumenty, UseParensForNegativeNumbers a GroupDigits mají následující nastavení.The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings.
| KonstantaConstant | DescriptionDescription |
|---|---|
TriState.True |
AnoTrue |
TriState.False |
NeFalse |
TriState.UseDefault |
Místní nastavení počítačeThe computer's regional settings |