Vbscript-if-else-statement
提供:Dev Guides
VBScript If Elseステートメント
*If* ステートメントは、ブール式とそれに続く1つ以上のステートメントで構成されます。 条件がTrueと言われている場合、 *If* 条件の下のステートメントが実行されます。 条件がFalseと言われた場合、 *Else* パートの下のステートメントが実行されます。
構文
TVBScriptの 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