|
Bay Six Software Beyond the Basics
|
View previous topic :: View next topic |
Author |
Message |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Jan 15th, 2012, 9:06pm Post subject: Exit_statement |
|
|
Code: | ***** 14-Jan-2012
Remarks
An Exit Do statement may appear inside a Do/Loop loop.
An Exit For statement may appear inside a For/Next loop.
Back to simple statements
***** 15-Jan-2012
Remarks
An Exit Do statement may appear inside a Do/Loop loop. This causes execution to
jump to the line following Loop.
An Exit For statement may appear inside a For/Next loop. This causes execution
to jump to the line following Next.
Unlike Liberty BASIC, Exit may be used to exit out of multiple nested loops. For
example two For/Next loops nested within a Do/Loop loop can be exited with a
single Exit Do.
Examples
Example 1: Validating user input
Do
Prompt "Enter an integer in the range 1 to 10", n
If n=Int(n) And n>=1 And n<=10 Then
Exit Do
End If
Loop While TrueExample 2: Exiting nested loops
Do
For i=1 To 10
For j=1 To 10
If Int(10*Rnd(0))=5 Then
Exit Do
End If
Next j
Next i
Loop While True
Notice "i=";i;CrLf;"j=";jSee also
Do/Loop statement
For/Next statement
Back to simple statements
***** |
_________________ Brent |
|
Back to top |
|
|
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Jan 31st, 2012, 8:49pm Post subject: Re: Exit_statement |
|
|
Code: | ***** 21-Jan-2012
Exit {Do|For}
***** 31-Jan-2012
Exit {Do|For|Loop|Sub}
*****
***** 21-Jan-2012
An Exit Do statement may appear inside a Do/Loop <#Do_Loop_statement>
loop. This causes execution to jump to the line following Loop.
***** 31-Jan-2012
An Exit Do or Exit Loop statement may appear inside a Do/Loop
<#Do_Loop_statement> loop. This causes execution to jump to the line
following Loop.
*****
***** 21-Jan-2012
Unlike Liberty BASIC, Exit may be used to exit out of multiple nested
***** 31-Jan-2012
An Exit Sub statement works identically to the Stop <#Stop_statement>
statement.
Unlike Liberty BASIC, Exit may be used to exit out of multiple nested
***** |
_________________ Brent |
|
Back to top |
|
|
|
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|