summaryrefslogtreecommitdiff
path: root/source/text/sbasic/shared/03090203.xhp
blob: fb2832414782c59ee717ac9968f124bf4825dafa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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="textsbasicshared03090203xml" indexer="include" status="PUBLISH">
<title xml-lang="en-US" id="tit">While...Wend Statement[Runtime]</title>
<filename>/text/sbasic/shared/03090203.xhp</filename>
</topic>
<history>
<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
</history>
</meta>
<body>

  <section id="whilewend">
  <bookmark xml-lang="en-US" branch="index" id="bm_id3150400"><bookmark_value>While;While...Wend loop</bookmark_value></bookmark><paragraph id="hd_id3150400" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03090203.xhp" name="While...Wend Statement[Runtime]">While...Wend Statement[Runtime]</link></paragraph>
  <paragraph xml-lang="en-US" role="paragraph" id="par_id3151211">When a program encounters a While statement, it tests the condition. If the condition is False, the program continues directly following the Wend statement. If the condition is True, the loop is executed until the program finds Wend and then jumps back to the<emph> While </emph>statement. If the condition is still True, the loop is executed again.</paragraph>
  </section>
  <paragraph xml-lang="en-US" id="par_id3151041" role="paragraph">Unlike the <link href="text/sbasic/shared/03090201.xhp" name="Do...Loop">Do...Loop</link> statement, you cannot cancel a <emph>While...Wend</emph> loop with <link href="text/sbasic/shared/03090412.xhp" name="Exit">Exit</link>. Never exit a While...Wend loop with <link href="text/sbasic/shared/03090302.xhp" name="GoTo">GoTo</link>, since this can cause a run-time error.</paragraph>
  <paragraph role="paragraph" id="par_id3145172" xml-lang="en-US">A Do...Loop is more flexible than a While...Wend.</paragraph>
  <paragraph role="heading" level="2" id="hd_id3155133" xml-lang="en-US">Syntax:</paragraph>
  <bascode>
<paragraph role="bascode" id="par_id3147288" xml-lang="en-US">While Condition [Statement] Wend</paragraph>
</bascode>
  <paragraph role="heading" level="2" id="hd_id3153139" xml-lang="en-US">Example:</paragraph>
<bascode>
  <paragraph role="bascode" id="par_id3159153" xml-lang="en-US">Sub ExampleWhileWend</paragraph>
  <paragraph role="bascode" id="par_id3151114" xml-lang="en-US">Dim stext As String</paragraph>
  <paragraph role="bascode" id="par_id3153143" xml-lang="en-US">Dim iRun As Integer</paragraph>
  <paragraph role="bascode" id="par_id3155306" xml-lang="en-US">    sText =&quot;This Is a short text&quot;</paragraph>
  <paragraph role="bascode" id="par_id3154011" xml-lang="en-US">    iRun = 1</paragraph>
  <paragraph role="bascode" id="par_id3147215" xml-lang="en-US">    While iRun &lt; Len(sText)</paragraph>
  <paragraph role="bascode" id="par_id3147427" xml-lang="en-US">        If Mid(sText,iRun,1 )&lt;&gt; &quot; &quot; Then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) )</paragraph>
  <paragraph role="bascode" id="par_id3149665" xml-lang="en-US">        iRun = iRun + 1</paragraph>
  <paragraph role="bascode" id="par_id3152939" xml-lang="en-US">    Wend</paragraph>
  <paragraph role="bascode" id="par_id3153189" xml-lang="en-US">    MsgBox sText,0,&quot;Text encoded&quot;</paragraph>
  <paragraph role="bascode" localize="false" id="par_id3145251" xml-lang="en-US">End Sub</paragraph>
</bascode>
 </body>
</helpdocument>