diff options
Diffstat (limited to 'helpcontent2/source/text/sbasic/shared/03120103.xhp')
-rw-r--r-- | helpcontent2/source/text/sbasic/shared/03120103.xhp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03120103.xhp b/helpcontent2/source/text/sbasic/shared/03120103.xhp new file mode 100644 index 000000000..976c53e7e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03120103.xhp @@ -0,0 +1,85 @@ +<?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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . +--> + +<meta> + <topic id="textsbasicshared03120103xml" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">Str Function</title> + <filename>/text/sbasic/shared/03120103.xhp</filename> + </topic> +</meta> + +<body> + <section id="str"> + <bookmark xml-lang="en-US" branch="index" id="bm_id3143272"> + <bookmark_value>Str function</bookmark_value> + </bookmark> + <h1 id="hd_id3143272"><variable id="Str_h1"><link href="text/sbasic/shared/03120103.xhp" name="Str Function">Str Function</link></variable></h1> + <paragraph id="par_id3155100" role="paragraph">The <literal>Str</literal> function converts the contents of variables into a string. It handles numeric values, dates, strings and currency values.</paragraph> + <paragraph id="par_id3146958" role="paragraph">Positive numbers are preceded by a blank space. Negative numbers are preceded by a minus sign.</paragraph> + <note id="par_id331641237252390">For numeric values the string returned by the <literal>Str</literal> function is locale-independent. Hence the dot is used as the decimal separator when needed.</note> + <paragraph role="paragraph" id="par_id601641237849695">If a string is passed as argument, it is returned without any changes.</paragraph> + <paragraph role="paragraph" id="par_id231641251937406">Dates are converted into locale-dependent strings.</paragraph> + </section> + <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/> + <bascode> + <paragraph id="par_id3149497" role="bascode">Str (Value As Variant)</paragraph> + </bascode> + <embed href="text/sbasic/shared/00000003.xhp#functvalue"/> + <paragraph id="par_id3146117" localize="false" role="paragraph">String</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#functparameters"/> + <paragraph id="par_id3149178" role="paragraph"> <emph>Value:</emph> Any value to be converted into a string.</paragraph> + <embed href="text/sbasic/shared/00000003.xhp#errorcode"/> + <embed href="text/sbasic/shared/00000003.xhp#err5"/> + <embed href="text/sbasic/shared/00000003.xhp#functexample"/> + <paragraph role="paragraph" id="par_id401641251970766">Below are some numeric examples using the <literal>Str</literal> function.</paragraph> + <bascode> + <paragraph id="par_idm1341439760" role="bascode" localize="false">Sub ExampleStr_1</paragraph> + <paragraph role="bascode" id="bas_id831641238784987"> ' Note the blank space at the beginning of the returned strings</paragraph> + <paragraph id="par_idm1341438528" role="bascode" localize="false"> MsgBox Str(10) ' " 10"</paragraph> + <paragraph id="par_idm1341437296" role="bascode" localize="false"> MsgBox Str(10.5) ' " 10.5"</paragraph> + <paragraph id="par_idm1341436064" role="bascode" localize="false"> MsgBox Str(-12345 + 1.3) ' " -12346.3"</paragraph> + <paragraph id="par_idm1341434832" role="bascode" localize="false"> MsgBox Str(10000 / 3) ' " 3333.33333333333"</paragraph> + <paragraph role="bascode" id="bas_id991641238830710"> ' Strings passed as arguments are left unchanged</paragraph> + <paragraph id="par_idm1341433584" role="bascode" localize="false"> MsgBox Str("A123") ' "A123"</paragraph> + <paragraph id="par_idm1341432272" role="bascode" localize="false">End Sub</paragraph> + </bascode> + <paragraph role="paragraph" id="par_id601641238259787">Use the <literal>LTrim</literal> function to remove the blank space at the beginning of the returned string.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id521641238327633">Sub ExampleStr_2</paragraph> + <paragraph role="bascode" localize="false" id="bas_id211641238327951"> MsgBox Str(10.5) ' " 10.5"</paragraph> + <paragraph role="bascode" localize="false" id="bas_id481641238328191"> MsgBox LTrim(Str(10.5)) ' "10.5"</paragraph> + <paragraph role="bascode" localize="false" id="bas_id51641238328726">End Sub</paragraph> + </bascode> + <paragraph role="paragraph" id="par_id881641252036753">The <literal>Str</literal> function can also handle <literal>Date</literal> variables.</paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="bas_id781641252076979">Sub ExampleStr_3</paragraph> + <paragraph role="bascode" localize="false" id="bas_id271641252077387"> Dim aDate as Date, aTime as Date</paragraph> + <paragraph role="bascode" localize="false" id="bas_id816412520776129"> aDate = DateSerial(2021, 12, 20)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id631641252077803"> aTime = TimeSerial(10, 20, 45)</paragraph> + <paragraph role="bascode" localize="false" id="bas_id311641252078019"> Print Str(aDate) ' "12/20/2021"</paragraph> + <paragraph role="bascode" localize="false" id="bas_id481641252230128"> Print Str(aTime) ' "10:20:45"</paragraph> + <paragraph role="bascode" localize="false" id="bas_id481641252078235">End sub</paragraph> + </bascode> + + <section id="relatedtopics"> + <embed href="text/sbasic/shared/03120104.xhp#Val_h1"/> + </section> +</body> +</helpdocument> |