Indicates if ValueToString agument is treated as a fraction or a percentage.
[Visual Basic 6.0] Property AdjustPercentage As Boolean
[Visual Basic .NET] Public Property AdjustPercentage As Boolean
[C#] public bool AdjustPercentage {get; set;}
[Java] public boolean isAdjustPercentage() throws IOException, AutomationException
[Java] public void setAdjustPercentage( boolean AdjustPercentage ) throws IOException, AutomationException
[C++]
HRESULT get_AdjustPercentage(
VARIANT_BOOL* adjust
);
[C++] HRESULT put_AdjustPercentage( VARIANT_BOOL adjust);
Parameters
adjust [out, retval]
adjust is a parameter of type VARIANT_BOOL
adjust [in]
adjust is a parameter of type VARIANT_BOOL
The AdjustPercentage property allows the conversion to and from fractions and sets or returns an indicator that tells how the ValueToString method's argument is treated in the associated INumberFormat interface.
The settings for AdjustPercentage are:
| Setting | Description |
|
False |
(Default) The arguments to the ValueToString and StrinToValue methods are assumed to be in percentage format already. For ValueToString, a percentage symbol (%) is appended to the value, and for StringToValue, this is removed. |
|
True |
The argument to the ValueToString method is treated as a fraction. The value is multiplied by 100 and a percent symbol (%) is appended. For StringToValue, the output is converted to a fraction (from a percentage)—it is divided by 100, and any percentage symbol is removed. |
Sub PercentageFormatExample()
Dim pPercentageFormat As IPercentageFormat
Dim dValue As Double, sV2S As String, dS2V As Double
Dim pNumberFormat As INumberFormat
Set pPercentageFormat = New PercentageFormat
Set pNumberFormat = pPercentageFormat
dValue = 0.5 ' Set the input value
'First try with a conversion between fractions and percentages
pPercentageFormat.AdjustPercentage = True
sV2S = pNumberFormat.ValueToString(dValue)
dS2V = pNumberFormat.StringToValue(sV2S)
MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & _
vbNewLine & "StringToValue('" & sV2S & "') = " & dS2V, , _
"PercentageFormat - AdjustPercentage = " & _
pPercentageFormat.AdjustPercentage
'Now try without converting between fractions and percentages
pPercentageFormat.AdjustPercentage = False
sV2S = pNumberFormat.ValueToString(dValue)
dS2V = pNumberFormat.StringToValue(sV2S)
MsgBox "ValueToString(" & dValue & ") = '" & sV2S & "'" & _
vbNewLine & "StringToValue('" & sV2S & "') = " & dS2V, , _
"PercentageFormat - AdjustPercentage = " & _
pPercentageFormat.AdjustPercentage
End Sub
IPercentageFormat Interface | IFractionFormat Interface | AngleFormat Class | IAngleFormat Interface | IPercentageFormat Interface | ICustomNumberFormat Interface | CurrencyFormat Class | LatLonFormat Class | FractionFormat Class | IRateFormat Interface | RateFormat Class | ILatLonFormat2 Interface | NumericFormat Class | CustomNumberFormat Class | INumericFormat Interface | PercentageFormat Class | IScientificNumberFormat Interface | ILatLonFormat Interface | INumberFormat Interface | ScientificFormat Class