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

asp do while 循環語法與do while實例教程

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

  在do while循環的另一種常用後 Next循環的循環在do while循環語句重復語句

  塊的次數不定重復的陳述或者當條件為真或直到條件變為True語法如下所示

  Do [While|Until] condition
  statements
Loop

  Do 
  statements
Loop [While|Until] condition

  在這方面這個循環內的代碼將執行至少一次的情況在有一個例子

  下面的例子定義了一個循環開始與i = 循環將繼續運行因為我只要小於或等於

  我將增加每次循環運行
Select ActionSelect AllTry It<%
Dim i use i as a counter
i = assign a value to i

  Do While i<= Output the values from to
  responsewrite(i & "<br >")
  i = i + increment the value of i for next time loop executes
Loop
%>
現在讓我們考慮一個更有用的例子創建下拉幾天幾個月或幾年清單您可以使

  用此登記表的代碼例如

  <%
creates an array
Dim month_array()
month_array() = "January"
month_array() = "February"
month_array() = "March"
month_array() = "April"
month_array() = "May"
month_array() = "June"
month_array() = "July"
month_array() = "August"
month_array() = "September"
month_array() = "October"
month_array() = "November"
month_array() = "December"

  Dim i use i as a counter

  responsewrite("<select name=""day"">" & vbCrLf)
i =
Do While i <=  
   responsewrite("<option value=" & i & ">" & i & "</option>" & vbCrLf)
   i = i +
Loop
responsewrite("</select>")

  responsewrite("<select name=""month"">" & vbCrLf)
i =
Do While i <=
   responsewrite("<option value=" & i & ">" & month_array(i) & "</option>"

  & vbCrLf)   
   i = i +
Loop
responsewrite("</select>")

  responsewrite("<select name=""year"">")
i =
Do Until i =    
   responsewrite("<option value=" & i & ">" & i & "</option>" & vbCrLf)   
   i = i +
Loop
responsewrite("</select>")
%>


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