User Tools

Site Tools


lrcontrolflow

Control Flow

  • Decisions

The term ‘decisions’ refers to the use of conditional statements to decide what to execute in your program. Conditional statements test if a given expression is ‘True’ or ‘False.’Then, statements are executed. Normally a condition uses an expression in which a comparison operator is used to compare two values or variables. KBasic supports all VB6 conditional statements and more.

  • Loops

The statements that control decisions and loops in KBasic are called control structures. Normally every command is executed only one time but in many cases it may be useful to run a command several times until a defined state has been reached. Loops repeat commands depending upon a condition. Some loops repeat commands while a condition is ‘True,’ other loops repeat commands while a condition is ‘False.’ There are other loops repeating a fixed number of times and some repeat for all elements of a collection.



Class : Classes are needed, when you would like use custom objects.

Module : Modules are needed, when you would like to organize large code parts

Choose : Returns one value from a list of values depending on the index.

Do...Loop Until : repeats until a condition is set

Do...Loop While : repeats statements while condition is set

Do Until...Loop : A group of statements enabling you to define a loop which will be repeated until a certain condition remains true.

Do While...Loop : A group of statements enabling you to define a loop which will be repeated until a certain condition remains true.

End : ends the execution of a program immediately

Exit Do : breaks out of a loop

Exit For : breaks out of a for loop

Exit Function : exits a function www.kbasic.com_images_vb6.jpg

Exit Sub : exits a sub www.kbasic.com_images_vb6.jpg

For Next : Defines a loop that runs for a specified number of times.

GoSub : jumps to the desired sub www.kbasic.com_images_vb6.jpg

GoTo : jumps to the desired label or line

If : single decision possibility

IIf : returns a value depending on an expression

Iterate Do : continues to iterate a loop if condition is set

Iterate For : continues to iterate a for loop if condition is set

On Error : jumps to desired label or line if an error occured www.kbasic.com_images_vb6.jpg

On...GoSub : jumps to the desired sub www.kbasic.com_images_vb6.jpg

On...GoTo : jumps to another line or label depending on an expression www.kbasic.com_images_vb6.jpg

Resume : continues execution after an error occured www.kbasic.com_images_vb6.jpg

Return : returns either from a gosub call or leaves the function or sub

Select Case : Multi-line conditional selection statement.

Stop : stops the running program

Switch : returns a value depending on an expression

System : exit program and returns to system www.kbasic.com_images_vb6.jpg

Try : TRY CATCH statement

While...End While : WHILE initiates a WHILE END WHILE loop. www.kbasic.com_images_vb6.jpg

While...WEnd : WHILE initiates a WHILE-WEND loop. www.kbasic.com_images_vb6.jpg

COMMENTS

How a comment should be

Some description here…

Example

some code

Written by AUTHOR

Date 2007-02-22

lrcontrolflow.txt · Last modified: 2013/04/09 22:57 (external edit)