VBScript如果-否则语句



一个如果语句包含一个布尔表达式,后跟一个或多个语句。如果条件为真,则执行如果条件下的语句。如果条件为假,则执行否则部分下的语句。

语法

VBScript 中if…else 语句的语法为 -

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

流程图

VBScript if...else statement

示例

<!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.htm
广告
© . All rights reserved.