asp-classic
ルーピング
サーチ…
For Loop
古典的なASPでは、 forキーワードを使ってforループを指定することができます。 for文では、カウンタをインクリメントする次の文が必要です。
For i = 0 To 10
Response.Write("Index: " & i)
Next
stepキーワードを使用すると、 次のステートメントでカウンタを変更する方法を変更できます。
For i = 10 To 1 Step -1
'VBS Comment
Next
forループを終了するには、 Exit Forステートメントを使用します
For i = 0 To 10
Response.Write("Index: " & i)
If i=7 Then Exit For 'Exit loop after we write index 7
Next
For...Each
ループを使用して、コレクション内の一連の定義済み要素をループで実行することもできます。例えば:
Dim farm, animal
farm = New Array("Dog", "Cat", "Horse", "Cow")
Response.Write("Old MacDonald had a Farm, ")
For Each animal In farm
Response.Write("and on that farm he had a " & animal & ".<br />")
Next
Do Loop
whileはwhileループと非常によく似ていますが、ループの繰り返しが不明な場合に一般的に使用されます。
一方を行います:
'Continues until i is greater than 10
Do While i <= 10
i = i + 1
Loop
'Or we can write it so the first loop always executes unconditionally:
'Ends after our first loop as we failed this condition on our previous loop
Do
i = i + 1
Loop While i <= 10
まで:
'Ends once i equates to 10
Do Until i = 10
i = i + 1
Loop
'Or we can write it so the first loop always executes unconditionally:
'Ends after our first loop as we failed this condition on our previous loop
Do
i = i + 1
Loop Until i=10
Doループの終了は、forループと似ていますが、 Exit Doステートメントを使用するだけです。
'Exits after i equates to 10
Do Until i = 10
i = i + 1
If i = 7 Then Exit Do
Loop
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow