Multiple conditions can be tested with an else if condition:

Example

@Code
Dim price=25
End Code
<html>
<body>
@If price>=30 Then
    @<p>The price is high.</p>
ElseIf price>20 And price<30 then
    @<p>The price is OK.</p>
Else
    @<p>The price is low.</p>
End If   
</body>
</html>
 

In the example above, if the first condition is true, it will be executed.

If not, then if the next condition is true, this condition will be executed.

You can have any number of else if conditions.

If none of the if or else if conditions are true, the last else block (without a condition) covers "everything else".



Practice Excercise Practice now