• asp中的循环语句


       在asp中,循环主要有以下几种(脚本语言为vbscript):
       1、do......1oop循环
        有两种:
        第一,“当型”do......lloop循环
        又分为两类:
        do while (条件语句)
        执行语句
        exit do
        loop
     示例:
      
    <%
    counter = 1
    thismonth = month(now())
    Do while counter < thismonth + 1
    response.write  (counter & " 月份 : ")
    response.write ("______________________________" & "<br><br>")
    If counter >13 then
    exit do
    end if
    counter = counter+1
    Loop
    %>


        do 
        执行语句
        exit do
        loop while 条件语句
      示例:
    <%
    counter = 1
    thismonth = month(now())
    Do
    response.write  (counter & " 月份 : ")
    response.write ("______________________________" & "<br><br>")
    If counter >13 then
    exit do
    end if
    counter = counter+1
    Loop while counter < thismonth + 1
    %>


        第二,“直到型”do......lloop循环
         do until 条件语句
         exit do
         loop
       实例:
     
    <%
    counter = 1
    thismonth = month(now())
    Do until counter=thismonth
    response.write  (counter & " 月份 : ")
    response.write ("______________________________" & "<br><br>")
    If counter >13 then
    exit do
    end if
    counter = counter+1
    Loop
    %>

    2、for循环
    分为两种:
    第一、for .....next 循环
    例如:
    dim i=0
    dim sum=0
    for i=1 to 10
    sum=sum+i
    next 
    第二,for each ......next 
    说明:For Each...Next: 对于集合中的每项或数组中的每个元素,重复执行一组语句。For Each...Next 循环与 For...Next 循环类似。For Each...Next 不是将语句运行指定的次数,而是对于数组中的每个元素或对象集合中的每一项重复一组语句。这在不知道集合中元素的数目时非常有用。它的语法如下: For Each element In group
    [statements]
    Exit For
    [statements]Next [element]
    如果 group 中有至少一个元素,就会进入 For Each 块执行。一旦进入循环,便首先对 group 中第一个元素执行循环中的所有语句。只要 group 中还有其他的元素,就会对每个元素执行循环中的语句。当 group 中没有其他元素时退出循环,然后从 Next 语句之后的语句继续执行。
      

  • 相关阅读:
    CMS .NET 程序框架 从2.0/3.5升级到4.0 版本后 需要调整的地方
    配置信息
    修改SQL Server 2005 数据库文件名字
    生成一行html
    安卓模拟器研究-root
    Win8.1屏幕亮度自动调节关闭方法
    ORA-01012:not logged on的解决办法
    ORA-00845: MEMORY_TARGET not supported on this system
    Linux vmstat命令实战详解
    Linux操作系统下Oracle主要监控工具介绍
  • 原文地址:https://www.cnblogs.com/liuzhengliang/p/1216566.html
Copyright © 2020-2023  润新知