文章詳情頁
asp循環(huán)語句總結(jié)
瀏覽:232日期:2022-06-05 16:04:55
asp的循環(huán)語句有以下幾類:
循環(huán)語句的作用就是重復(fù)執(zhí)行程序代碼,循環(huán)可分為三類:一類在條件變?yōu)椤凹佟敝爸貜?fù)執(zhí)行語句,一類在條件變?yōu)椤罢妗敝爸貜?fù)執(zhí)行語句,另一類按照指定的次數(shù)重復(fù)執(zhí)行語句。在VBScript 中可使用下列循環(huán)語句:
Do...Loop: 當(dāng)(或直到)條件為“真”時(shí)循環(huán)。
While...Wend: 當(dāng)條件為“真”時(shí)循環(huán)。
For...Next: 指定循環(huán)次數(shù),使用計(jì)數(shù)器重復(fù)運(yùn)行語句。
For Each...Next: 對于集合中的每項(xiàng)或數(shù)組中的每個(gè)元素,重復(fù)執(zhí)行一組語句。
現(xiàn)在看幾個(gè)例子:
<body>
do while....loop<br />
<%
"do while....loop 類似.net中的while(){}
i=6
Do while i < 10
response.Write(i&"<br>")
i=i+1
Loop
%>
do ....loop until<br />
<%
"do while....loop 類似.net中的while(){}
i=6
Do
response.Write(i&"<br>")
i=i+1
Loop until i < 10
%>
while....wend <br />
<%
i=10
while i<20
response.Write(i&"<br>")
i=i+1
wend
%>
For...Next<br />
<%
for i=0 to 10 " 包括0到10
response.Write(i&"<br>")
if i=5 then
exit for
end if
next
%>
For.....each....next<br />
<%
dim array(3)
array(1)="A"
array(2)="B"
array(3)="C"
for each a in array
response.Write(a&"<br>")
next
%>
</body>
</html>
從數(shù)據(jù)庫讀取數(shù)據(jù)
<%
while not rs.eof
%>
<li><a href="#"><%=rs("classname")%></a></li>
<%
rs.movenext
wend
%>
以上就是asp循環(huán)語句小結(jié),希望對大家掌握asp循環(huán)語句有所幫助。
標(biāo)簽:
ASP
相關(guān)文章:
1. ASP.NET MVC實(shí)現(xiàn)單個(gè)圖片上傳、限制圖片格式與大小并在服務(wù)端裁剪圖片2. ASP.NET Core依賴注入DI容器的方法實(shí)現(xiàn)3. asp.net core服務(wù)限制堆內(nèi)存大小的操作方法4. ASP.NET堆和棧三之引用類型對象拷貝和內(nèi)存分配5. ASP.Net MVC利用NPOI導(dǎo)入導(dǎo)出Excel的示例代碼6. asp(vbs)Rs.Open和Conn.Execute的詳解和區(qū)別及&H0001的說明7. ASP.NET泛型二之泛型的使用方法8. Spring AspectJ AOP框架注解原理解析9. asp程序執(zhí)行數(shù)據(jù)庫的效率提升建議10. 讓 Asp 與 XML 交互
排行榜

網(wǎng)公網(wǎng)安備