ASP條件語句之IF語句

條件語句之 if ... then ... else 語句
用來判斷條件是 true 或 false ,並根據判斷結果來執行指定的語句,一般條件是用比較運算符對值或變量進行比較來表達。
if ... then ... else 能夠根據須要進行嵌套使用,能夠寫成 elseif 。
示例:
如下爲引用內容:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> 條件語句之 if ... then ... else 語句 </title>
</head>
<body>

<%
dim a          '聲明一個變量
a=9            '給變量賦值
if a<8 then
response.write "循環語句"         '條件語句
elseif a>6 and a<18 then          'elseif ... then 嵌套
response.write "條件語句"
else
response.Write "sub過程"
end if
%>

</body>
</html>
運行結果:條件語句,修改 a 的值在知足不一樣的條件時將會獲得不一樣的結果 。
相關文章
相關標籤/搜索