Name

If...Then...Else Statement

Synopsis


Standard syntax:
If condition Then
    [statements]
[ElseIf condition-n Then
    [elseifstatements] ...
[Else
    [elsestatements]]
End If

One-line syntax:
If condition Then [statements] [Else elsestatements]
condition required; Boolean

An expression returning either True or False or an object type

statements optional

Program code to be executed if condition is true

condition-n optional

Same as condition

elseifstatements optional

Program code to be executed if the corresponding condition-n is True

elsestatements optional

Program code to be executed if the corresponding condition or condition-n is False

Description

Executes a statement or block of statements based on the Boolean (True or False) value of an expression.

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.