ASP条件语句之IF语句

来源:互联网 发布:以下哪些淘宝禁售商品 编辑:程序博客网 时间:2024/05/22 12:19

本文链接:http://www.desteps.com/wprogram/asp/827.html

条件语句之 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 的值在满足不同的条件时将会得到不同的结果 。