Navigation:  thinBasic language > Program Flow >

IF / THEN / ELSE / ELSEIF / END IF

Previous pageReturn to chapter overviewNext page

 

Description

 

Create IF/THEN/ELSE constructs with multiple lines and/or conditions.

 

Syntax 1

 

IF numeric_expression THEN

{statements}

[ELSEIF numeric_expression THEN

{statements}]

[ELSE

{statements}]

END IF

 

Syntax 2

 

IF numeric_expression THEN {statements}

 

Returns

 

Parameters

 

Remarks

 

Restrictions

 

See also

 

Examples

 

RANDOMIZE

 

DIM X   AS NUMBER VALUE ( RND * 500 ) + 1

DIM Msg AS STRING

 

IF X <= 10 THEN

Msg = X & ": The number <= 10"

ELSEIF X <= 20 THEN

Msg = X & ": The number > 10 and <= 20"

ELSE

IF X < 50 THEN

  Msg = X & ": The number is > 20 and less than 50"

ELSEIF X < 100 THEN

  Msg = X & ": Greater than 49 and less than 100"

ELSE

  Msg = X & ": The number is 100 or greater"

END IF

END IF

 

MSGBOX 0, Msg

 

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com