It conditionally executes a group of statements depending upon value of the expression. |
If...Then…Else block is used to define several blocks of statements ,in order to execute one block. |
Syntax: |
If <condition>then |
[statements] |
Else if <condition>Then |
[else if statement] . . . |
Else |
[elsestatement] |
End If |
Example: |
If a<10 then |
a=a+10 |
elseif a>15 then |
a=a-10 |
else |
a=100 |
end if |
Note that: |
1.Both Else and ElseIf statements are optional. You can have any number of ElseIfstatements as you want in an If block. But no ElseIf statement can appear after the Else. |
2.Block If statements can be nested. Nested means a block contained within one another. |
3.In fact If…Then is just a special case of If…then…Else. |
4.If none of ElseIf statement is True ,then the statement following Else will execute. |
Menu
If...Then..Else Statement
Subscribe to:
Posts (Atom)