📜  VBA-决策

📅  最后修改于: 2020-11-19 09:11:11             🧑  作者: Mango


通过决策,程序员可以控制脚本或其部分之一的执行流程。该执行由一个或多个条件语句控制。

以下是大多数编程语言中常见的典型决策结构的一般形式。

VBA中的决策声明

VBA提供以下类型的决策声明。单击以下链接以查看其详细信息。

Sr.No. Statement & Description
1 if statement

An if statement consists of a Boolean expression followed by one or more statements.

2 if..else statement

An if else statement consists of a Boolean expression followed by one or more statements. If the condition is True, the statements under If statements are executed. If the condition is false, the Else part of the script is executed.

3 if…elseif..else statement

An if statement followed by one or more ElseIf statements, that consists of Boolean expressions and then followed by an optional else statement, which executes when all the condition become false.

4 nested if statements

An if or elseif statement inside another if or elseif statement(s).

5 switch statement

A switch statement allows a variable to be tested for equality against a list of values.