- VBScript教程
- VBScript - 主頁
- VBScript - 概述
- VBScript - 語法
- VBScript - 啟用
- VBScript - 佈局
- VBScript - 變數
- VBScript - 常量
- VBScript - 運算子
- VBScript - 決策
- VBScript - 迴圈
- VBScript - 事件
- VBScript - Cookie
- VBScript - 數字
- VBScript - 字串
- VBScript - 陣列
- VBScript - 日期
- VBScript高階版
- VBScript - 過程
- VBScript - 對話方塊
- VBScript -面向物件
- VBScript - 正則表示式
- VBScript - 錯誤處理
- VBScript - 其他語句
- VBScript有用資源
- VBScript - 問答
- VBScript - 快速指南
- VBScript - 有用資源
- VBScript - 討論
VBScript如果-否則語句
一個如果語句包含一個布林表示式,後跟一個或多個語句。如果條件為真,則執行如果條件下的語句。如果條件為假,則執行否則部分下的語句。
語法
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.htm
廣告