ASP中的do while循环问题

2025-05-18 01:32:46
推荐回答(4个)
回答1:

给你一个例子:
....
Response.write("

")
do while not rs.eof
Response.write("")
Response.write("")
rs.movenext
if rs.eof then
Response.write("")
exit do
else
Response.write("")
End if
loop
Response.write("
" &rs("..") &" 
" &rs("..") &"
")

其实要实现这个功能就是在循环里多加几个RS.MOVENEXT,但加了的话你就必须得再判断是否到结尾了。
按同样的方法可以实现多重并列输出。

回答2:

楼上的二位别吵了,看洒家给你们解开谜底:


<%dim i
i=0%>
<%do while not rs.eof%>
i=i+1
<%if int(i/2)=i/2 then%>

<%else%>

<%end if%>
<%
rs.movenext
loop
%>
<%=rs("1")%><%=rs("1")%>


定义一个变量i,每循环一次如果int(i/2)=i/2则被二整除就换行,同理int(i/n)=i/n则是被n整除即换行,

回答3:



<%do while not rs.eof%>

<%
rs.movenext
loop
%>

<%=rs(1)%>

楼上的兄弟,好像没有必要判断吧,只要到了eof则do自动跳出了

回答4:


<%dim i
i=0%>
<%do while not rs.eof%>

<%if i mod 2 =0 then%>

<%else%>

<%end if%>
<%i=i+1
rs.movenext
loop
%>
<%=rs("1")%><%=rs("1")%>


其实为了效率还是不要用rs.eof 应该用for循环。