亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

ASP中if語句、select 、while循環(huán)的使用方法

瀏覽:360日期:2022-06-05 10:49:41
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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=gb2312" />
<title><%="頁面標(biāo)題"%></title>
</head>

<body>
<%="多條件判斷"%>
<%
response.Write("<br />")
response.Write("利用response對象的Write方法輸出地內(nèi)容!")

%>
<br />
<%

dim a,b
a=200
b=300
response.Write("兩數(shù)之和為:")
response.Write(a+b)
response.Write("<br />")
if a=100 then
response.Write("a=100,第一個條件滿足。")
elseif a=200 then
response.Write("a=200,第二個條件滿足。")
elseif a=300 then
response.Write("a=300,第三個條件滿足。")
else
response.Write("三個條件都不滿足。")
end if
%>
<%
response.Write("<br />")
dim textnumber
textnumber=200
select case textnumber
 case 100
 response.Write("數(shù)值為100, 條件滿足!")
 case 200
 response.Write("數(shù)值為200,條件滿足 !")
 case 300
 response.Write("數(shù)值為300 ,條件滿足!")
 case else
 response.Write("以上條件,條件都不滿足!")
 end select


%>
<%
response.Write("<br />")
dim i,sum
i=0
sum=0
 while i<=100
 sum=sum+i
 i=i+1
wend
response.Write("100以內(nèi)所有整數(shù)的和為:")
response.Write(sum)
%>
<%
response.Write("<br />")
dim w,s
w=0
s=0
do 
s=s+w
w=w+1
loop while w<=100
response.Write("100之內(nèi)的所有整數(shù)之和為:")
response.Write(s)
response.Write("<br/>")
response.Write("w的值是:")
response.Write(w)
%>

</body>
</html>

具體的介紹就不多說了,大家看下實例就可以了

考慮后期的便于閱讀,小編再為大家整理一下

asp if語句

①if A then B

②if A then

B

end if

③if A then

B

else

C

end if

④if A then

B

elseif C then

D

end if

⑤if A then

B

elseif C then

D

else

E

end if

If....Then.....Else

在下面的情況中,您可以使用 If...Then...Else 語句:
在條件為 true 時,執(zhí)行某段代碼
選擇兩段代碼之一來執(zhí)行時
如果需要在條件為 true 時只執(zhí)行一行語句,可以把代碼寫為一行:
if i=10 Then msgbox "Hello"
在上面的代碼中,沒有 .else.. 語句。我們僅僅讓代碼在條件為 true 時執(zhí)行一項操作(當(dāng) i 為 10 時)。
假如我們需要在條件為 true 時執(zhí)行不止一條語句,那么就必須在一行寫一條語句,然后使用關(guān)鍵詞 "End If" 來結(jié)束這個語句:

if i=10 Then
  msgbox "Hello"
  i = i+1
end If

在上面的代碼中,同樣沒有 .else.. 語句。我們僅僅讓代碼在條件為 true 時執(zhí)行了多項操作。
假如我們希望在條件為 true 時執(zhí)行某條語句,并當(dāng)條件不為 true 時執(zhí)行另一條語句,就必須添加關(guān)鍵詞 "Else":

if i=10 then
  msgbox "Hello"
else
  msgbox "Goodbye"
end If

當(dāng)條件為 true 時會執(zhí)行第一段代碼,當(dāng)條件不成立時執(zhí)行第二段代碼(當(dāng) i 不等于 10 時)。
If....Then.....Elseif
假如你希望選擇多套代碼之一來執(zhí)行,可以使用if...then...elseif語句:

if payment="Cash" then
  msgbox "You are going to pay cash!"
 elseif payment="Visa" then
  msgbox "You are going to pay with visa."
 elseif payment="AmEx" then
  msgbox "You are going to pay with American Express."
 else
  msgbox "Unknown method of payment."
end If

Select Case
假如你希望選擇多套代碼之一來執(zhí)行,可以使用 SELECT 語句:

select case payment
 case "Cash"
  msgbox "You are going to pay cash"
 case "Visa"
  msgbox "You are going to pay with visa"
 case "AmEx"
  msgbox "You are going to pay with American Express"
 case Else
  msgbox "Unknown method of payment"
end select

以上代碼的工作原理:首先,我們需要一個簡單的表達式(常常是一個變量),并且這個表達式會被做一次求值運算。然后,表達式的值會與每個 case 中的值作比較,如果匹配,被匹配的 case 所對應(yīng)的代碼會被執(zhí)行。

標(biāo)簽: ASP
相關(guān)文章:
主站蜘蛛池模板: 国产日韩亚洲欧美 | 视频播放在线观看精品视频 | 久久日本精品99久久久 | 在线久综合色手机在线播放 | 在线国产不卡 | 国产乱码精品一区二区三区网页版 | 综合激情区视频一区视频二区 | 中文字幕一区二区在线视频 | 一级一级黄色片 | 欧美一区二区三区四区在线观看 | 国产污片在线观看 | xxxx鞠婧祎xxxx网站视频观看 | 黄网站视频观看免费 | 天天看天天射天天碰 | 日本黄色高清网站 | 国产白嫩美女在线观看 | 国产日韩精品一区在线不卡 | 视频黄在线观看 | 久久精品国产91久久综合麻豆自制 | 在线观看91精品国产不卡免费 | 国产在线视频一区二区三区 | 久久99国产亚洲精品 | 九九九九九九精品免费 | 尤物在线视频观看 | 日韩不卡一区二区 | 亚洲狠狠成人综合网 | 国产精品色午夜视频免费看 | 天天摸天天碰色综合网 | 国产成人小视频在线观看 | 欧美日韩在线高清 | 亚洲一区二区三区中文字幕5566 | 免费视频片在线观看 | 成人免费淫片在线费观看 | 亚洲视频手机在线 | 成人黄色免费观看 | 免费毛片在线视频 | 成人区视频爽爽爽爽爽 | 日韩国产片 | 黄色无遮挡 | 一级毛片特级毛片免费的 | 成人亚洲国产 |