Page 91 - Computer Class 08
P. 91
IF-Then-Else Statement
When an If....Then...Else statement is encountered, condition is tested. If condition is True,
the statements following Then are executed. If condition is False , each Else statement (if there
are any) is evaluated in order.
Syntax If (condition) THEN
Block of Visual Basic statements
ELSE
Block of Visual Basic statements
END IF
It is necessary to write the END IF statement where as ELSE part is not necessary.
For Example:
Open your form in Visual Basic and Labels, text and command buttons in it.
Let’s Learn...
Let’s
Learn...
To add if then else statement.
1. Double-click on the Command button to bring the code window.
1
Computer-8 91