国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP中if語句、select 、while循環的使用方法

2020-07-26 23:05:25
字體:
來源:轉載
供稿:網友
<%@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><%="頁面標題"%></title></head><body><%="多條件判斷"%><%response.Write("<br />")response.Write("利用response對象的Write方法輸出地內容!")%><br /><%dim a,ba=200b=300response.Write("兩數之和為:")response.Write(a+b)response.Write("<br />")if a=100 thenresponse.Write("a=100,第一個條件滿足。")elseif a=200 thenresponse.Write("a=200,第二個條件滿足。")elseif a=300 thenresponse.Write("a=300,第三個條件滿足。")elseresponse.Write("三個條件都不滿足。")end if%><%response.Write("<br />")dim textnumbertextnumber=200select case textnumber case 100 response.Write("數值為100, 條件滿足!") case 200 response.Write("數值為200,條件滿足 !") case 300 response.Write("數值為300 ,條件滿足!") case else response.Write("以上條件,條件都不滿足!") end select%><%response.Write("<br />")dim i,sumi=0sum=0 while i<=100 sum=sum+i i=i+1wendresponse.Write("100以內所有整數的和為:")response.Write(sum)%><%response.Write("<br />")dim w,sw=0s=0do s=s+ww=w+1loop while w<=100response.Write("100之內的所有整數之和為:")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 時,執行某段代碼
選擇兩段代碼之一來執行時
如果需要在條件為 true 時只執行一行語句,可以把代碼寫為一行:
if i=10 Then msgbox "Hello"
在上面的代碼中,沒有 .else.. 語句。我們僅僅讓代碼在條件為 true 時執行一項操作(當 i 為 10 時)。
假如我們需要在條件為 true 時執行不止一條語句,那么就必須在一行寫一條語句,然后使用關鍵詞 "End If" 來結束這個語句:

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

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

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

當條件為 true 時會執行第一段代碼,當條件不成立時執行第二段代碼(當 i 不等于 10 時)。
If....Then.....Elseif
假如你希望選擇多套代碼之一來執行,可以使用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
假如你希望選擇多套代碼之一來執行,可以使用 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 所對應的代碼會被執行。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黄平县| 凌源市| 鄂托克前旗| 台江县| 江口县| 齐齐哈尔市| 大渡口区| 大庆市| 西畴县| 辽宁省| 黄陵县| 新郑市| 德保县| 万源市| 敖汉旗| 右玉县| 保山市| 襄城县| 景泰县| 永仁县| 五台县| 信丰县| 渝中区| 高阳县| 清水河县| 林口县| 疏勒县| 双峰县| 陆丰市| 溧阳市| 张北县| 合作市| 汤阴县| 河曲县| 衡阳市| 承德市| 富蕴县| 乌恰县| 南乐县| 洞头县| 榆社县|