asp 運算子(算術運 比較運 邏輯運算子)

來源:互聯網
上載者:User

本文章簡介一下asp 運算子(算術運 比較運 邏輯運算子)與運算子的優先順序簡單代碼。


 1.算術運算子
 執行個體:
  example10.asp
 2.比較子
 3.邏輯運算子
 執行個體:
  example12.asp
 4.運算子的優先順序
<%
if request.form("submit") = "提交" then       '使用者點擊【提交】按鈕
 if instr(request.form("str"),"@")<=0 then     'instr函數判斷使用者輸入的字串中是否包含@字元,如果包含,返回的值是@字元在字串中第一次出現的位置
  response.write("<script>alert('輸入的字串中不包含@字元')</script>") '不包含,給出提示
 else          '包含,給出提示
  response.write("<script>alert('輸入的字串中包含@字元')</script>")
 end if
end if
%>
<html>
<head>
<meta http-equiv="content-language" content="zh-cn">
<title>example17</title> 
</head>
<body>
 <form method="post" action="example17.asp" name=form1>
  <p align="center">請輸入字串:<input type="text" name="str" size="20"></p>
  <p align="center"><input type="submit" value="提交" name="submit" onclick="check()"><input type="reset" value="重設" name="b2"></p>
 </form>
</body>
</html>

執行個體二

<script language="vbscript" runat="server">
 sub example18()
  dim varweek    '聲明變數
  varweek = weekday(now)                  '擷取代表今天是星期幾的整數
  response.write("<center>")  '中間對齊
  response.write("<font size=10>") '網頁上顯示的字型大小
  if varweek=1 then   '添加多個elseif 子句的條件判斷
   response.write("今天星期日") '如果是1,網頁上顯示"今天星期日"
  elseif varweek=2 then
   response.write("今天星期一")
  elseif varweek=3 then
   response.write("今天星期二")
  elseif varweek=4 then
   response.write("今天星期三")
  elseif varweek=5 then
   response.write("今天星期四")
  elseif varweek=6 then
   response.write("今天星期五")
  elseif varweek=7 then
   response.write("今天星期六")
  end if
  response.write("</font>")
end sub
</script>
<html>
<head>
<title>example18</title>
</head>
<body>
<%
 example18
%>
</body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.