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