summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/03170010.xhp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /helpcontent2/source/text/sbasic/shared/03170010.xhp
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--helpcontent2/source/text/sbasic/shared/03170010.xhp118
1 files changed, 118 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03170010.xhp b/helpcontent2/source/text/sbasic/shared/03170010.xhp
new file mode 100644
index 000000000..2202cd123
--- /dev/null
+++ b/helpcontent2/source/text/sbasic/shared/03170010.xhp
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+ <!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ -->
+
+ <meta>
+ <topic id="textsbasicshared03170010xml" indexer="include" status="PUBLISH">
+ <title id="tit" xml-lang="en-US">FormatNumber Function [VBA]</title>
+ <filename>/text/sbasic/shared/03170010.xhp</filename>
+ </topic>
+ </meta>
+ <body>
+ <section id="formatnumber">
+ <bookmark id="bm_id541542193473856" xml-lang="en-US" branch="hid/zzzz" localize="false"/>
+ <bookmark xml-lang="en-US" branch="index" id="bm_id661542193659245">
+ <bookmark_value>FormatNumber function</bookmark_value>
+ </bookmark>
+ <paragraph id="hd_id871542193473857" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03170010.xhp" name="FormatNumber Function [VBA]">FormatNumber [VBA]</link></paragraph>
+ <paragraph id="par_id351542193473858" role="paragraph" xml-lang="en-US">Returns a string with a number formatting applied to a numeric expression.</paragraph>
+ </section>
+ <embed href="text/sbasic/shared/00000003.xhp#vbasupport"/>
+ <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
+ <paragraph role="bascode" id="par_id291542194090512" xml-lang="en-US" localize="false">FormatNumber( expression, numDigitsAfterDecimal as Integer, includeLeadingDigit as Integer, <br/> useParensForNegativeNumbers as Integer, groupDigits as Integer )</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#functvalue"/>
+ <paragraph role="paragraph" id="par_id761542194361212" xml-lang="en-US">String</paragraph>
+
+ <embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
+
+ <paragraph id="par_id240720170117391741" role="paragraph" xml-lang="en-US"><emph>expression</emph>: Required. The numeric expression to be formatted.</paragraph>
+
+ <paragraph role="paragraph" id="par_id631542195798758" xml-lang="en-US"><emph>numDigitsAfterDecimal</emph>: Optional. A numeric value specifying the number of digits that should be displayed after the decimal. If omitted, it defaults to the value -1, meaning that the default settings for user interface locale should be used.</paragraph>
+
+ <paragraph role="paragraph" id="par_id961542200034362" xml-lang="en-US"><emph>includeLeadingDigit</emph>: Optional. A <link href="text/sbasic/shared/03040000.xhp#addvbaconstants" name="vbtristate">vbTriState</link> enumeration value, specifying whether a leading zero should be displayed for fractional values.</paragraph>
+
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id561542198440051" role="listitem" xml-lang="en-US"><emph>vbTrue or -1</emph>: Display a leading zero.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id21542198550868" role="listitem" xml-lang="en-US"><emph>vbFalse or 0</emph>: Do not display leading zeros.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id241542199046808" role="listitem" xml-lang="en-US"><emph>vbUseDefaults or -2</emph>: Use the user interface locale settings. This is the default when omitted.</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id311542201637647" xml-lang="en-US"><emph>useParensForNegativeNumbers</emph>: Optional. A <link href="text/sbasic/shared/03040000.xhp#addvbaconstants" name="vbtristate">vbTriState</link> enumeration value specifying whether negative numbers should be encased in parenthesis.</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id561543198440051" role="listitem" xml-lang="en-US"><emph>vbTrue or -1</emph>: Use parenthesis for negative numbers.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id21542398550868" role="listitem" xml-lang="en-US"><emph>vbFalse or 0</emph>: Do not display parenthesis.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id241542191246808" role="listitem" xml-lang="en-US"><emph>vbUseDefaults or -2</emph>: Same as vbFalse. This is the default when omitted.</paragraph>
+ </listitem>
+ </list>
+
+ <paragraph role="paragraph" id="par_id531542201968815" xml-lang="en-US"><emph>groupDigits</emph>: Optional. A <link href="text/sbasic/shared/03040000.xhp#addvbaconstants" name="vbtristate">vbTriState</link> enumeration value specifying the number should be grouped (into thousands, etc.), using the group delimiter that is specified on the system's regional settings.</paragraph>
+
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id561543198560051" role="listitem" xml-lang="en-US"><emph>vbTrue or -1</emph>: Group digits.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id215423985506768" role="listitem" xml-lang="en-US"><emph>vbFalse or 0</emph>: Do not group digits.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id241542191267808" role="listitem" xml-lang="en-US"><emph>vbUseDefaults or -2</emph>: Same as vbFalse. This is the default when omitted.</paragraph>
+ </listitem>
+ </list>
+ <embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
+ <embed href="text/sbasic/shared/00000003.xhp#err13"/>
+ <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
+ <bascode>
+ <paragraph role="bascode" id="par_id381542204697430" xml-lang="en-US" localize="false">Sub TestFormatNumber</paragraph>
+ <paragraph role="bascode" id="par_id551542204266762" xml-lang="en-US" localize="false">testName = "Test 1: positive, 2 decimals"</paragraph>
+ <paragraph role="bascode" id="par_id561542204276644" xml-lang="en-US" localize="false">str2 = "12.20"</paragraph>
+ <paragraph role="bascode" id="par_id341542204281478" xml-lang="en-US" localize="false">str1 = FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse)</paragraph>
+ <paragraph role="bascode" id="par_id771542204286220" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+
+ <paragraph role="bascode" id="par_id411542204290664" xml-lang="en-US" localize="false">testName = "Test 2: negative, 20 decimals, use leading zero"</paragraph>
+ <paragraph role="bascode" id="par_id411542204295496" xml-lang="en-US" localize="false">str2 = "-0.20000000000000000000"</paragraph>
+ <paragraph role="bascode" id="par_id391542204301416" xml-lang="en-US" localize="false">str1 = FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse)</paragraph>
+ <paragraph role="bascode" id="par_id671542204307459" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+
+ <paragraph role="bascode" id="par_id741542204311861" xml-lang="en-US" localize="false">testName = "Test 3: negative, 20 decimals, no leading zero"</paragraph>
+ <paragraph role="bascode" id="par_id871542204316094" xml-lang="en-US" localize="false">str2 = "-.20000000000000000000"</paragraph>
+ <paragraph role="bascode" id="par_id911542204322988" xml-lang="en-US" localize="false">str1 = FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse)</paragraph>
+ <paragraph role="bascode" id="par_id61542204328859" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+
+ <paragraph role="bascode" id="par_id781542204333400" xml-lang="en-US" localize="false">testName = "Test 4: negative, no leading zero, use parens"</paragraph>
+ <paragraph role="bascode" id="par_id161542204338478" xml-lang="en-US" localize="false">str2 = "(.20)"</paragraph>
+ <paragraph role="bascode" id="par_id251542204342658" xml-lang="en-US" localize="false">str1 = FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse)</paragraph>
+ <paragraph role="bascode" id="par_id421542204347269" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+
+ <paragraph role="bascode" id="par_id181542204351589" xml-lang="en-US" localize="false">testName = "Test 5: negative, default leading zero, use parens"</paragraph>
+ <paragraph role="bascode" id="par_id561542204357496" xml-lang="en-US" localize="false">str2 = "(0.20)"</paragraph>
+ <paragraph role="bascode" id="par_id341542204361912" xml-lang="en-US" localize="false">str1 = FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse)</paragraph>
+ <paragraph role="bascode" id="par_id151542204366706" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+
+ <paragraph role="bascode" id="par_id841542204371456" xml-lang="en-US" localize="false">testName = "Test 6: group digits"</paragraph>
+ <paragraph role="bascode" id="par_id711542204376020" xml-lang="en-US" localize="false">str2 = "-12,345,678.00"</paragraph>
+ <paragraph role="bascode" id="par_id481542204380404" xml-lang="en-US" localize="false">str1 = FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue)</paragraph>
+ <paragraph role="bascode" id="par_id971542204385212" xml-lang="en-US" localize="false">msgbox( "FormatNumber returned: " + str1 + ", Expected: " + str2)</paragraph>
+ <paragraph role="bascode" id="par_id11542204687786" xml-lang="en-US" localize="false">End Sub</paragraph>
+ </bascode>
+ <section id="relatedtopics">
+ <embed href="text/sbasic/shared/00000003.xhp#VBAMath"/>
+ </section>
+</body>
+</helpdocument>