zoukankan      html  css  js  c++  java
  • 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 语句之后的语句继续执行。
      

  • 相关阅读:
    mybatis中的缓存
    mybatis中的延迟加载
    mybatis中的ResultMap关联映射
    mubatis中为什么实体类要继承Serializable
    【经验总结-markdown】markdown字体和颜色设置
    【算法】动态规划
    【刷题-PAT】A1135 Is It A Red-Black Tree (30 分)
    【刷题-PAT】A1126 Eulerian Path (25 分)
    【刷题-PAT】A1119 Pre- and Post-order Traversals (30 分)
    【刷题-PAT】A1114 Family Property (25 分)
  • 原文地址:https://www.cnblogs.com/liuzhengliang/p/1216566.html
Copyright © 2011-2022 走看看