曲径通幽论坛

标题: if..else 语句 [打印本页]

作者: easy    时间: 2013-4-2 17:45
标题: if..else 语句
if 语句使用示例:
<html>
<body>
<%
    dim a, b
    a = 2
    b = 1
   
    if a = 1 and b = 1 then
        response.Write("今天有促销信息")
    else
        response.Write("今天没有促销信息")
    end if
   
%>
</body>
</html>
输出:今天没有促销信息 。

可以使用 if not
<html>
<body>
<%
    dim a, b
    a = 2
    b = 1
   
    if not a = 1 and b = 1 then
        response.Write("今天有促销信息")
    else
        response.Write("今天没有促销信息")
    end if
   
%>
</body>
</html>
输出:今天有促销信息。

使用 elseif
<html>
<body>
<%
    dim a, b
    a = 50
    b = 80
    if a > 100 then
        response.Write("今天有促销信息")
    elseif b > 70 then
        response.Write("今天有促销信息")
    else
        response.Write("今天没有促销信息")
   
    end if
   
%>
</body>
</html>
输出:今天有促销信息。

注意:if 和 elseif 后面的 then 不要漏掉。




欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2