国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

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

發(fā)布時(shí)間:2021-08-17 12:10 來(lái)源: 閱讀:0 作者: 欄目: ASP 歡迎投稿:712375056

<%@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><%="頁(yè)面標題"%></title>
</head>

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

%>
<br />
<%

dim a,b
a=200
b=300
response.Write("兩數之和為:")
response.Write(a+b)
response.Write("<br />")
if a=100 then
response.Write("a=100,第一個(gè)條件滿(mǎn)足。")
elseif a=200 then
response.Write("a=200,第二個(gè)條件滿(mǎn)足。")
elseif a=300 then
response.Write("a=300,第三個(gè)條件滿(mǎn)足。")
else
response.Write("三個(gè)條件都不滿(mǎn)足。")
end if
%>
<%
response.Write("<br />")
dim textnumber
textnumber=200
select case textnumber
 case 100
 response.Write("數值為100, 條件滿(mǎn)足!")
 case 200
 response.Write("數值為200,條件滿(mǎn)足 !")
 case 300
 response.Write("數值為300 ,條件滿(mǎn)足!")
 case else
 response.Write("以上條件,條件都不滿(mǎn)足!")
 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以?xún)人姓麛档暮蜑椋?)
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之內的所有整數之和為:")
response.Write(s)
response.Write("<br/>")
response.Write("w的值是:")
response.Write(w)
%>

</body>
</html>

具體的介紹就不多說(shuō)了,大家看下實(shí)例就可以了

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

asp if語(yǔ)句

①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 語(yǔ)句:
在條件為 true 時(shí),執行某段代碼
選擇兩段代碼之一來(lái)執行時(shí)
如果需要在條件為 true 時(shí)只執行一行語(yǔ)句,可以把代碼寫(xiě)為一行:
if i=10 Then msgbox "Hello"
在上面的代碼中,沒(méi)有 .else.. 語(yǔ)句。我們僅僅讓代碼在條件為 true 時(shí)執行一項操作(當 i 為 10 時(shí))。
假如我們需要在條件為 true 時(shí)執行不止一條語(yǔ)句,那么就必須在一行寫(xiě)一條語(yǔ)句,然后使用關(guān)鍵詞 "End If" 來(lái)結束這個(gè)語(yǔ)句:

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

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

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

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

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
假如你希望選擇多套代碼之一來(lái)執行,可以使用 SELECT 語(yǔ)句:

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

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

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

97无码人妻一区二区三区蜜桃| 麻豆精产国品一二三产品| 在线观看片A免费不卡观看| 无码少妇一区二区浪潮免费| 国产一区二区在线视频| 国产清纯在线一区二区|