67 lines
4.4 KiB
XML
67 lines
4.4 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
* 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 .
|
|
-->
|
|
<helpdocument version="1.0">
|
|
<meta>
|
|
<topic id="textsbasicshared03090103xml" indexer="include" status="PUBLISH">
|
|
<title id="tit" xml-lang="en-US">IIf Function</title>
|
|
<filename>/text/sbasic/shared/03090103.xhp</filename>
|
|
</topic>
|
|
<history>
|
|
<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
|
|
</history>
|
|
</meta>
|
|
<body>
|
|
<section id="iif">
|
|
<bookmark xml-lang="en-US" branch="index" id="bm_id3155420"><bookmark_value>IIf function</bookmark_value>
|
|
</bookmark>
|
|
<h1 id="hd_id3155420"><link href="text/sbasic/shared/03090103.xhp">IIf Function</link></h1>
|
|
<paragraph role="paragraph" id="par_id3145610" xml-lang="en-US">Returns one of two possible function results, depending on the logical value of the evaluated expression.</paragraph>
|
|
</section>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
|
|
<bascode>
|
|
<paragraph role="bascode" id="par_id3147560" xml-lang="en-US">IIf (Bool As Boolean, Variant1 As Variant, Variant2 As Variant) As Variant</paragraph>
|
|
</bascode>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
|
|
<paragraph role="paragraph" id="par_id3153381" xml-lang="en-US">
|
|
<emph>Bool</emph>: Any expression that you want to evaluate. If the expression evaluates to <emph>True</emph>, the function returns the value of Variant1, otherwise it returns the value of Variant2.</paragraph>
|
|
<paragraph role="paragraph" id="par_id3150870" xml-lang="en-US">
|
|
<emph>Variant1, Variant2</emph>: Any expression, one of which will be returned as the function result, depending on the logical evaluation.</paragraph>
|
|
<note id="par_id541598638231139">IIf evaluates both <literal>Variant1</literal> and <literal>Variant2</literal> even if it returns only one of them. If one of the expressions results in error, the function returns the error. For example, do not use IIF to bypass a possible division by zero result.</note>
|
|
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
|
|
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
|
|
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
|
|
<bascode>
|
|
<paragraph role="bascode" id="par_id1001598638460925" xml-lang="en-US">REM Returns the maximum of 3 values</paragraph>
|
|
<paragraph role="bascode" id="par_id11598638500752" xml-lang="en-US" localize="false">Function Max (A As Double, B As Double, C, As Double) As Double</paragraph>
|
|
<paragraph role="bascode" id="par_id271598638528057" xml-lang="en-US" localize="false"> Max = IIf( A >= B, A, B)</paragraph>
|
|
<paragraph role="bascode" id="par_id281598638539101" xml-lang="en-US" localize="false"> Max = IIf( C >= Max, C, Max)</paragraph>
|
|
<paragraph role="bascode" id="par_id521598638553550" xml-lang="en-US" localize="false">End Function</paragraph>
|
|
<paragraph role="bascode" id="par_id161598638840133" xml-lang="en-US">REM Bad usage of function IIf</paragraph>
|
|
<paragraph role="bascode" id="par_id571598638863628" xml-lang="en-US" localize="false">Function Inverse(A As Double) As Double</paragraph>
|
|
<paragraph role="bascode" id="par_id171598638875498" xml-lang="en-US" localize="false"> Inverse = IIf( A = 0, 0, 1/A )</paragraph>
|
|
<paragraph role="bascode" id="par_id451598638883642" xml-lang="en-US" localize="false">End Function</paragraph>
|
|
</bascode>
|
|
|
|
<section id="relatedtopics">
|
|
<paragraph role="paragraph" id="par_id161588865796615"><link href="text/sbasic/shared/03090101.xhp">If</link> or <link href="text/sbasic/shared/03090102.xhp">Select Case</link> statements</paragraph>
|
|
<paragraph role="paragraph" id="par_id281588865818334"><link href="text/sbasic/shared/03090410.xhp">Switch</link> function</paragraph>
|
|
</section>
|
|
|
|
</body>
|
|
</helpdocument>
|