if

Read(3100) Label: if,

Here’s how to use if statment.

if x

Description:

The introduction of if statement.

Syntax:

if x

Note:

The statement executes the if code block if x is true and skip if code block if x is false.

Parameter:

x

A Boolean expression

Example:

 

A

B

 

1

=6

 

16

2

if A1>5

 

if code block

3

 

>A1=A1+10

Related function:

if x …{ else { if x} }

if x … else

if x else

if x …{ else { if x }… }

Description:

The introduction of if statement.

Syntax:

if  x 

      The if code block

{else {if x}}

  The else or else if code block. When else or else if is not found, then else or else if code block does not exist.

Note:

If the conditional expression x is evaluated as true, then execute the if code block, otherwise, skip the if code block and execute the code block of else or else if.

Parameter:

x

A Boolean expression

Example:

 

A

B

C

 

1

=13

=2

 

C1 returns 7.

2

if(A1>10)

 

 

 

3

 

if(B1==1)

>C1=2+3

 

4

 

else if(B1==2)

>C1=3+4

 

5

 

else if(B1==3)

>C1=4+5

 

6

else if(A1>5)

 

 

 

7

 

>C1=5+6

 

 

Related function:

if x … else

if x else

if x

if x …else …

Description:

The introduction of if statement.

Syntax:

if  x   else  

Note:

if and else are in the same line. If x is true, then execute the code between if and else; if x is false, execute the code after else till the end of this line. The else… part can be omitted.

Parameter:

x

A boolean expression

Example:

 

A

B

C

D

 

1

=2

 

 

 

A1 returns 7.

2

if A1>5

>A1=A1+4

else

>A1=A1+5

 

Related functions:

if x …{ else { if x}… }

if x else

if x

if x else

Description:

The introduction of if statement.

Syntax:

if  x

 

else

   

Note:

if and else must be in the same column. Execute if code block if x is true and execute else code block if x is false. The else part can be omitted.

Parameter:

x

A Boolean expression

Example:

 

A

B

 

1

=3

 

 

2

if A1>5

 

if code block.

3

 

>A1=A1+10

4

else

 

else code block.

5

 

>A1=A1+15

Related function:

if x …{ else { if x}… }

if x … else

if x