Strings.FormatPercent(Object, Int32, TriState, TriState, TriState) Metoda

Definice

Vrátí výraz formátovaný jako procento (vynásobený 100) s koncovým znakem%.Returns an expression formatted as a percentage (that is, multiplied by 100) with a trailing % character.

public static string FormatPercent (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 FormatPercent (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 FormatPercent : obj * int * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState * Microsoft.VisualBasic.TriState -> string
Public Function FormatPercent (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 napravo od desetinné čárky je zobrazeno.Numeric value indicating how many places to the right of the decimal are displayed. Výchozí hodnota je-1, což znamená, že se používá nastavení národního prostředí.Default value is -1, which indicates that the locale settings are used.

IncludeLeadingDigit
TriState

Nepovinný parametr.Optional. TriState konstanta, která označuje, zda se má počáteční nula zobrazit pro desetinné hodnoty.TriState constant that indicates whether or not a leading zero displays 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 uvádět záporné hodnoty.TriState constant that indicates whether or not 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

String

Výraz formátovaný jako procento (vynásobený 100) s koncovým znakem%.An expression formatted as a percentage (that is, multiplied by 100) with a trailing % character.

Výjimky

Typ není numerický.Type is not numeric.

Příklady

Tento příklad ilustruje použití FormatPercent funkce.This example illustrates the use of the FormatPercent function.

Dim testNumber As Single = 0.76
' Returns "76.00%".
Dim testString As String = FormatPercent(testNumber)

Poznámky

Při vynechání jednoho nebo více volitelných argumentů jsou hodnoty vynechaných argumentů poskytnuty 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.Default Místní nastavení počítačeThe computer's regional settings

Platí pro

Viz také