VBScript If Else 语句
If 语句由一个布尔表达式后跟一个或多个语句组成。 如果条件为 True,则执行 If 条件下的语句。 如果条件为False,则执行Else部分下的语句。
语法
VBScript 中 if…else 语句的语法是 −
If(boolean_expression) Then Statement 1 ..... ..... Statement n Else Statement 1 ..... .... Statement n End If
流程图
示例
<!DOCTYPE html>
<html>
<body>
<script language = "vbscript" type = "text/vbscript">
Dim a : a = 5
Dim b : b = 25
If a > b Then
Document.write "a is Greater"
Else
Document.write "b is Greater"
End If
</script>
</body>
</html>
执行上述代码时,会产生以下结果 −
b is Greater

vbscript_decisions.html