PercentNegativePattern Property

NumberFormatInfo.PercentNegativePattern Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the format pattern for negative percent values.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Property PercentNegativePattern As Integer

Property Value

Type: System.Int32
The format pattern for negative percent values. The default for InvariantInfo is 0, which represents "-n %", where "%" is the PercentSymbol and n is a number.

ExceptionCondition
ArgumentOutOfRangeException

The property is being set to a value that is less than 0 or greater than 11.

InvalidOperationException

The property is being set and the NumberFormatInfo object is read-only.

This property has one of the values in the following table. The symbol "%" is the PercentSymbol, the symbol "-" is the NegativeSign, and n is a number.

Value

Associated pattern

0

-n %

1

-n%

2

-%n

3

%-n

4

%n-

5

n-%

6

n%-

7

-% n

8

n %-

9

% n-

10

% -n

11

n- %

The following example formats a numeric value using each of the 12 possible values of the PercentNegativePattern property for the current culture.


Imports System.Globalization

Public Module Example
   Public Sub Demo(outputBlock As System.Windows.Controls.TextBlock)
      ' Create a read-write NumberFormatInfo object for the current culture.
      Dim numberInfo As NumberFormatInfo = DirectCast(NumberFormatInfo.CurrentInfo.Clone, _
                                                      NumberFormatInfo)
      Dim value As Decimal = -0.1324d

      ' Assign each possible value to the PercentNegativePattern property.
      For ctr As Integer = 0 to 11
         numberInfo.PercentNegativePattern = ctr
         outputBlock.Text += String.Format("{0,2}: {1}", _
                                           ctr, value.ToString("P", numberInfo)) + vbCrLf
      Next
   End Sub
End Module
' The example displays the following output:
'        0: -13.24 %
'        1: -13.24%
'        2: -%13.24
'        3: %-13.24
'        4: %13.24-
'        5: 13.24-%
'        6: 13.24%-
'        7: -% 13.24
'        8: 13.24 %-
'        9: % 13.24-
'       10: % -13.24
'       11: 13.24- %


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft