summaryrefslogtreecommitdiff
path: root/helpcontent2/source/text/sbasic/shared/03120301.xhp
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/source/text/sbasic/shared/03120301.xhp')
-rwxr-xr-xhelpcontent2/source/text/sbasic/shared/03120301.xhp120
1 files changed, 120 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03120301.xhp b/helpcontent2/source/text/sbasic/shared/03120301.xhp
new file mode 100755
index 0000000000..dc6af8e735
--- /dev/null
+++ b/helpcontent2/source/text/sbasic/shared/03120301.xhp
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc..
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************--><helpdocument version="1.0">
+<meta>
+<topic id="textsbasicshared03120301xml" indexer="include" status="PUBLISH">
+<title xml-lang="en-US" id="tit">Format Function [Runtime]</title>
+<filename>/text/sbasic/shared/03120301.xhp</filename>
+</topic>
+<history>
+<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
+<lastedited date="2003-10-31T00:00:00">converted from old format - fpe</lastedited>
+</history>
+</meta>
+<body>
+
+
+ <section id="format">
+ <bookmark xml-lang="en-US" branch="index" id="bm_id3153539"><bookmark_value>Format;function</bookmark_value></bookmark><paragraph id="hd_id3153539" role="heading" level="1" oldref="1" l10n="U" xml-lang="en-US"><link href="text/sbasic/shared/03120301.xhp" name="Format Function [Runtime]">Format Function [Runtime]</link></paragraph>
+ <paragraph role="paragraph" id="par_id3156042" l10n="U" xml-lang="en-US" oldref="2">Converts a number to a string, and then formats it according to the format that you specify.</paragraph>
+ </section>
+ <paragraph role="heading" level="2" id="hd_id3145090" l10n="U" xml-lang="en-US" oldref="4">Syntax:</paragraph>
+ <paragraph role="paragraph" id="par_id3153527" l10n="U" xml-lang="en-US" oldref="5">Format (Number [, Format As String])</paragraph>
+ <paragraph role="heading" level="2" id="hd_id3149178" l10n="U" xml-lang="en-US" oldref="6">Return value:</paragraph>
+ <paragraph role="paragraph" id="par_id3148474" l10n="U" xml-lang="en-US" oldref="7">String</paragraph>
+ <paragraph role="heading" level="2" id="hd_id3159176" l10n="U" xml-lang="en-US" oldref="8">Parameters:</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3149415" xml-lang="en-US" oldref="9"><emph>Number:</emph> Numeric expression that you want to convert to a formatted string.</paragraph>
+ <paragraph l10n="U" xml-lang="en-US" oldref="10" role="paragraph" id="par_id3147531"><emph>Format:</emph> String that specifies the format code for the number. If <emph>Format</emph> is omitted, the Format function works like the <emph>Str</emph> function.</paragraph>
+ <paragraph role="heading" level="2" id="hd_id3147561" l10n="U" xml-lang="en-US" oldref="47">Formatting Codes</paragraph>
+ <paragraph role="paragraph" id="par_id3147265" l10n="U" xml-lang="en-US" oldref="11">The following list describes the codes that you can use for formatting a number:</paragraph>
+ <paragraph l10n="U" xml-lang="en-US" role="paragraph" id="par_id3153380" oldref="12"><emph>0:</emph> If <emph>Number</emph> has a digit at the position of the 0 in the format code, the digit is displayed, otherwise a zero is displayed.</paragraph>
+ <paragraph xml-lang="en-US" role="paragraph" id="par_id3151210" l10n="U" oldref="13">If <emph>Number</emph> has fewer digits than the number of zeros in the format code, (on either side of the decimal), leading or trailing zeros are displayed. If the number has more digits to the left of the decimal separator than the amount of zeros in the format code, the additional digits are displayed without formatting.</paragraph>
+ <paragraph xml-lang="en-US" role="paragraph" id="par_id3151176" l10n="U" oldref="14">Decimal places in the number are rounded according to the number of zeros that appear after the decimal separator in the <emph>Format </emph>code.</paragraph>
+ <paragraph l10n="U" xml-lang="en-US" oldref="15" role="paragraph" id="par_id3154123"><emph>#:</emph> If <emph>Number</emph> contains a digit at the position of the # placeholder in the <emph>Format</emph> code, the digit is displayed, otherwise nothing is displayed at this position.</paragraph>
+ <paragraph role="paragraph" id="par_id3148452" l10n="U" xml-lang="en-US" oldref="16">This symbol works like the 0, except that leading or trailing zeroes are not displayed if there are more # characters in the format code than digits in the number. Only the relevant digits of the number are displayed.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3159150" xml-lang="en-US" oldref="17"><emph>.:</emph> The decimal placeholder determines the number of decimal places to the left and right of the decimal separator.</paragraph>
+ <paragraph role="paragraph" id="par_id3159252" l10n="U" xml-lang="en-US" oldref="18">If the format code contains only # placeholders to the left of this symbol, numbers less than 1 begin with a decimal separator. To always display a leading zero with fractional numbers, use 0 as a placeholder for the first digit to the left of the decimal separator.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3153368" xml-lang="en-US" oldref="19"><emph>%:</emph> Multiplies the number by 100 and inserts the percent sign (%) where the number appears in the format code.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3149481" xml-lang="en-US" oldref="20"><emph>E- E+ e- e+ :</emph> If the format code contains at least one digit placeholder (0 or #) to the right of the symbol E-, E+, e-, or e+, the number is formatted in the scientific or exponential format. The letter E or e is inserted between the number and the exponent. The number of placeholders for digits to the right of the symbol determines the number of digits in the exponent.</paragraph>
+ <paragraph role="paragraph" id="par_id3149262" l10n="U" xml-lang="en-US" oldref="21">If the exponent is negative, a minus sign is displayed directly before an exponent with E-, E+, e-, e+. If the exponent is positive, a plus sign is only displayed before exponents with E+ or e+.</paragraph>
+ <paragraph role="paragraph" id="par_id3148617" l10n="U" xml-lang="en-US" oldref="23">The thousands delimiter is displayed if the format code contains the delimiter enclosed by digit placeholders (0 or #).</paragraph>
+ <paragraph role="paragraph" id="par_id3163713" l10n="U" xml-lang="en-US" oldref="29">The use of a period as a thousands and decimal separator is dependent on the regional setting. The actual character displayed as a decimal separator depends on the number format in your system settings. The examples shown here assume that the regional setting is &quot;US&quot;.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3152887" xml-lang="en-US" oldref="24"><emph>- + $ ( ) space:</emph> A plus (+), minus (-), dollar ($), space, or brackets entered directly in the format code is displayed as a literal character.</paragraph>
+ <paragraph role="paragraph" id="par_id3148576" l10n="U" xml-lang="en-US" oldref="25">To display characters other than the ones listed here, you must precede it by a backslash (\), or enclose it in quotation marks (&quot; &quot;).</paragraph>
+ <paragraph role="paragraph" id="par_id3153139" l10n="U" xml-lang="en-US" oldref="26">\ : The backslash displays the next character in the format code.</paragraph>
+ <paragraph role="paragraph" id="par_id3153366" l10n="U" xml-lang="en-US" oldref="27">Characters in the format code that have a special meaning can only be displayed as literal characters if they are preceded by a backslash. The backslash itself is not displayed, unless you enter a double backslash (\\) in the format code.</paragraph>
+ <paragraph role="paragraph" id="par_id3155411" l10n="U" xml-lang="en-US" oldref="28">Characters that must be preceded by a backslash in the format code in order to be displayed as literal characters are date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, :), numeric-formatting characters (#, 0, %, E, e, comma, period), and string-formatting characters (@, &amp;, &lt;, &gt;, !).</paragraph>
+ <paragraph role="paragraph" id="par_id3145749" l10n="U" xml-lang="en-US" oldref="30">You can also use the following predefined number formats. Except for &quot;General Number&quot;, all of the predefined format codes return the number as a decimal number with two decimal places.</paragraph>
+ <paragraph role="paragraph" id="par_id3150113" l10n="U" xml-lang="en-US" oldref="31">If you use predefined formats, the name of the format must be enclosed in quotation marks.</paragraph>
+ <paragraph role="heading" level="2" id="hd_id3149377" l10n="U" xml-lang="en-US" oldref="32">Predefined format</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3154730" xml-lang="en-US" oldref="33"><emph>General Number:</emph> Numbers are displayed as entered.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3153158" xml-lang="en-US" oldref="34"><emph>Currency:</emph> Inserts a dollar sign in front of the number and encloses negative numbers in brackets.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3154490" xml-lang="en-US" oldref="35"><emph>Fixed:</emph> Displays at least one digit in front of the decimal separator.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3153415" xml-lang="en-US" oldref="36"><emph>Standard:</emph> Displays numbers with a thousands separator.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3150715" xml-lang="en-US" oldref="37"><emph>Percent:</emph> Multiplies the number by 100 and appends a percent sign to the number.</paragraph>
+ <paragraph l10n="U" role="paragraph" id="par_id3153836" xml-lang="en-US" oldref="38"><emph>Scientific:</emph> Displays numbers in scientific format (for example, 1,00E+03 for 1000).</paragraph>
+ <paragraph role="paragraph" id="par_id3153707" l10n="U" xml-lang="en-US" oldref="39">A format code can be divided into three sections that are separated by semicolons. The first part defines the format for positive values, the second part for negative values, and the third part for zero. If you only specify one format code, it applies to all numbers.</paragraph>
+ <embed href="text/sbasic/shared/00000003.xhp#languageformat"/>
+ <embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
+ <embed href="text/sbasic/shared/00000003.xhp#err5"/>
+ <paragraph role="heading" level="2" id="hd_id3149019" l10n="U" xml-lang="en-US" oldref="40">Example:</paragraph>
+ <paragraph role="paragraph" id="par_id3156054" l10n="U" xml-lang="en-US" oldref="41">Sub ExampleFormat</paragraph>
+ <paragraph role="paragraph" id="par_id3148993" l10n="U" xml-lang="en-US" oldref="42">MsgBox Format(6328.2, &quot;##,##0.00&quot;) </paragraph>
+ <paragraph role="paragraph" id="par_id3147339" l10n="U" xml-lang="en-US" oldref="46">REM displays for example 6,328.20 in English locale, 6.328,20 in German locale</paragraph>
+ <paragraph role="paragraph" id="par_id3156382" l10n="U" xml-lang="en-US" oldref="43">End Sub</paragraph>
+
+
+ </body>
+</helpdocument>