If...Then..Statement |
The If...Then statement is used to evaluate whether a condition is True or False. |
You can use If…Then block to execute one or more statements conditionally. |
Syntax: |
If <condition> Then |
[statements] |
Else |
[else statements] |
End If |
Example: |
if a>5 Then a=a+10 |
Here condition is that 'a' should be greater than 5 and if it is true then 'a' should be incremented by 10. |
[Statements] :- One or more statements separated by colons; executed if condition is True. |
Note that: |
1.A single line of If…Then does not use End If statement. |
Syntax:- |
If condition Then statement. |
But if you use this in more than one line ,then syntax will be If…Then…End If. |
2.If anything other than a comment appears after Then on the same line, the statement is treated as a single line If statement. |
3.A block If statement must be the first statement on a line. The block If must end with an End If statement. |
4.When a If condition is tested ,then If condition is True, the statements following Then are executed,otherwise not. |
Wednesday, February 25, 2009
If...Then..Statement
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment