Strings.FormatCurrency(Object, Int32, TriState, TriState, TriState) Metoda
Definice
Vrací výraz formátovaný jako hodnota měny pomocí symbolu měny definovaného na ovládacím panelu systému.Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.
public static string FormatCurrency (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 FormatCurrency (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 FormatCurrency : obj * int * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState -> string
Public Function FormatCurrency (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.Default value is -1, which indicates that the computer's regional settings are used.
- IncludeLeadingDigit
- TriState
Nepovinný parametr.Optional. TriState výčet, který označuje, zda je u zlomkových hodnot zobrazeno počáteční nula.TriState enumeration that indicates whether or not a leading zero is displayed for fractional values. Hodnoty jsou uvedeny v části "poznámky".See "Remarks" for values.
- UseParensForNegativeNumbers
- TriState
Nepovinný parametr.Optional. TriState výčet, který označuje, zda se mají v závorkách uvádět záporné hodnoty.TriState enumeration that indicates whether or not to place negative values within parentheses. Hodnoty jsou uvedeny v části "poznámky".See "Remarks" for values.
- GroupDigits
- TriState
Nepovinný parametr.Optional. TriState výčet, který označuje, zda jsou čísla seskupena pomocí oddělovače skupin uvedeného v místním nastavení počítače.TriState enumeration that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings. Hodnoty jsou uvedeny v části "poznámky".See "Remarks" for values.
Návraty
Výraz formátovaný jako hodnota měny pomocí symbolu měny definovaného na ovládacím panelu systému.An expression formatted as a currency value using the currency symbol defined in the system control panel.
Výjimky
Počet číslic za desetinnou čárkou je větší než 99.Number of digits after decimal point is greater than 99.
Typ není numerický.Type is not numeric.
Příklady
Následující příklad ilustruje použití FormatCurrency funkce.The following example illustrates the use of the FormatCurrency function.
Dim testDebt As Double = -4456.43
Dim testString As String
' Returns "($4,456.43)".
testString = FormatCurrency(testDebt, , , TriState.True, TriState.True)
Poznámky
Při vynechání jednoho nebo více volitelných argumentů se místo toho použijí vyhovující hodnoty pro místní nastavení počítače.When one or more optional arguments are omitted, the computer's matching regional-settings values are used instead.
Pozice symbolu měny relativně vzhledem k hodnotě měny je určena místními nastaveními systému.The position of the currency symbol relative to the currency value is determined by the system's regional 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 s výjimkou počáteční nuly, která přichází na Number kartě.However, it may be changed programmatically by using the .NET Framework, except leading zero, which comes from the Number tab.
IncludeLeadingDigitArgumenty, UseParensForNegativeNumbers a GroupDigits přebírají následující hodnoty výčtu třístavové.The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments take the following TriState enumeration values.
| HodnotaValue | PopisDescription |
|---|---|
TriState.True |
AnoTrue |
TriState.False |
NeFalse |
TriState.UseDefault |
Místní nastavení počítačeThe computer's regional settings |