Collabora Office 24.04 帮助
Returns a string with a number formatting applied to a numeric expression. A percent sign is appended to the returned string.
FormatPercent( expression, [numDigitsAfterDecimal As Integer], [includeLeadingDigit As Integer], _
[useParensForNegativeNumbers As Integer], [groupDigits As Integer] ) As String
Sub TestFormatNumber
Const UseComputerRegionalSettings = -1
MsgBox FormatPercent(12.2, NumDigitsAfterDecimal:=2) ' 1220.00% if selected user interface is english
MsgBox FormatPercent("-,2", 2, IncludeLeadingDigit:=vbTrue) ' -20,00% if french user interface
MsgBox FormatPercent("-0.2", 2) ' -20.00% for en-US, -0,00 for fr-CA, de-AT or pt-BR
MsgBox FormatPercent(-0.2, UseComputerRegionalSettings, UseParensForNegativeNumbers:=vbTrue) ' (20,00)% if pt-BR
MsgBox FormatPercent("-0,2", UseComputerRegionalSettings, vbUseDefault, vbTrue) ' (20,00)% if german
MsgBox FormatPercent("-12345678", -1, vbUseDefault, vbUseDefault, GroupDigits:=vbTrue) ' -1 234 567 800,00% for fr-BE
End Sub