VBScript If 语句



If 语句由一个布尔表达式后跟一条或多条语句组成。如果条件为真,则执行If 条件下方的语句。如果条件为假,则执行If 循环后的语句。

语法

VBScript 中If 语句的语法如下 −

If(boolean_expression) Then
   Statement 1
	.....
	.....
   Statement n
End If

流程图

VBScript if statement

示例

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim a : a = 20
         Dim b : b = 10

         If a > b Then
            Document.write "a is Greater than b"
         End If

      </script>
   </body>
</html>

执行上述代码后,将生成以下结果 −

a is Greater than b
vbscript_decisions.htm
广告
© . All rights reserved.