当前位置:首页 > 唯美句子

ASP中如何实现for循环 ASP循环语句

ASP中如何实现for循环

这问题问的。。。

一个实例

<%

for i = 1 to 5

a=a+i

next

response.write(a)'看看输出多少

%>

再一个实例

<%

for i = 1 to 5 step 2

a=a+i

next

response.write(a)'看看输出多少

%>

asp循环语句

1、for语句一行后面可以加step参数,请问是什么作用?为什么我加了step 5,执行和结果就变成了1<br>2<br>,也就是循环减半了。

step步长 a的取值依次为1、6、11 只有1 6 的时候才进入循环进行i++

所以只输出1 2

2、我查了相关资料,next后面可以接For后面的参数a,但我改成next a后出错,提示“语句未结束”?

据我所知next后不能跟参数的

3、结束循环用什么语句?

如果要跳出循环 可以用exit for

请采纳。

ASP脚本循环语句详细教学图

在ASP里怎样写for循环语句

%

Response.Write "108"

for i = 108 to 10 step -10

Response.write " - " & 10

next

Response.Write " = " & i

'结果:108 - 10 - 10 - 10 - 10 - 10 - 10 - 10 - 10 - 10 - 10 = 8

%>

循环语句,asp循环,asp双循环,asp嵌套循环

其实你可以用一个SQL语句来得到记录集.

do while not rsMenu.eof

set rsMenuTwo = server.createobject("ADODB.recordset")

msSql = "select * from mb_so_status where sts='A' and Type_ID='"&rsMenu("Type_ID")&"'"

rsMenuTwo.open msSql,Conn,3,1

"输出A表内容"

do while not rsMenuTwo.eof

"输出B表内容"

rsMenuTwo.movenext

loop

rsMenuTwo.close

set rsMenuTwo=thiong

rsMenu.movenext

loop

rsMenu.close

set rsMenu=thiong

ASP脚本循环语句详细教学图

ASP循环语句

<%

dim a

for a=1 to 100-1

Response.Write(a&"<br>")

next

%>

这个结果显示的最后a=99

<%

dim a

for a=1 to 100-1

next

Response.Write(a&"<br>")

%>