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 的值在知足不一样的条件时将会获得不一样的结果 。
相关文章
相关标签/搜索