Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. If...Then...Else Statement (Visual Basic)
In this articleConditionally executes a group of statements, depending on the value of an expression. Syntax
Quick links to example codeThis article includes several examples that illustrate uses of the
Parts
If the expression is a
Nullable
RemarksMultiline syntaxWhen an The In the multiline syntax, the Tip The Select...Case Statement might be more useful when you evaluate a single expression that has several possible values. Single-Line syntaxYou can use the single-line syntax for a single condition with code to execute if it's true. However, the multiple-line syntax provides more structure and flexibility and is easier to read, maintain, and debug. What follows the In the single-line syntax, you can have multiple statements executed as the result of an Multiline syntax exampleThe following example illustrates the use of the multiline syntax of the
Nested syntax exampleThe following example contains nested
Single-Line syntax exampleThe following example illustrates the use of the single-line syntax.
See also
FeedbackSubmit and view feedback for Which logical operators perform shortWhich logical operators perform short-circuit evaluation? Short-circuit evaluation is performed with the not operator.
Does Python use the same symbols for the assignment operator?Python uses the same symbols for the assignment operator and the equality operator. Short-circuit evaluation is performed with the not operator. The decision structure that has two possible paths of execution is known as _____. The not operator is a unary operator and it must be a compound expression.
Which structure determines the order in which a set of statements executes?A control structure is a logical design that controls the order in which a set of statements execute.
Does the If statement causes one or more statements to execute only when a Boolean expression is true?The if statement causes one or more statements to execute only when a Boolean expression is true. The if statement is used to create a decision structure, which allows a program to have more than one path of execution.
|