熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp For Next 循環語句語法與實例

2022-06-13   來源: .NET編程 

  For Next循環使用時你要執行一段代碼多次集數語法如下
For counter = initial_value to  finite_value [Step increment]
  statements
Next
For語句指定計數器變量及其初步和有限的價值 Next語句增加了對抗一個變量

  選的步驟關鍵字允許增加或減少的值指定計數器變量

  有一個很簡單的例子

  <%@ language="vbscript" %>
<%
For i = to Step use i as a counter
 responsewrite("The number is " & i & "<br />")
Next
%>

  復雜實例

  Select ActionSelect AllTry It<%@ language="vbscript" %>
<%
responsewrite("<h>Multiplication table</h>")
responsewrite("<table border= width=%")

  For i = to              this is the outer loop
   responsewrite("<tr>")
   responsewrite("<td>" & i & "</td>")
 
   For j = to           inner loop
        responsewrite("<td>" & i * j & "</td>")
   Next repeat the code and move on to the next value of j 

  responsewrite("</tr>")
Next repeat the code and move on to the next value of i

  responsewrite("</table>")
%>


From:http://tw.wingwit.com/Article/program/net/201311/14415.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.