tailieunhanh - asp net 2.0 all in one desk reference for Dummies PHẦN 6
Hai trong số các biến thể sử dụng từ khi nhà nước điều kiện khác sử dụng từ Cho đến. Hai trong số họ đặt điều kiện vào đầu vòng lặp, hai điều kiện cuối cùng. Nếu khi từ được sử dụng, vòng lặp được lặp đi lặp lại miễn là điều kiện kiểm tra thật. Nhưng nếu bạn chỉ định thay vào đó, vòng lặp | 440 Working with For Next Loops To continue a loop as long as an expression evaluates to False use Not as part of the condition test. For example Dim x As Integer 0 While Not x 5 x br x x 1 End While Here the loop repeats as long as x is not equal to 5. Utilizing Do loops A Do loop is like a While loop but it has more flexibility in determining exactly when the condition that signals the end of the loop is tested. The Do loop can actually take one of four different forms Do While condition statements Loop Do statements Loop While condition Do Until condition statements Loop Do statements Loop Until condition Two of these variations use the word While to state the condition the other two use the word Until. Two of them place the condition at the beginning of the loop the other two place the condition at the end. If the word While is used the loop is repeated as long as the condition tests True. But if you specify Until instead the loop repeats itself for as long as the condition tests False. In other words the loop repeats until the condition becomes True. The position of the condition determines whether the condition is tested before or after the loop executes once. If you place the condition at the beginning of the loop the condition is evaluated before any statements in the loop are executed. As a result it s possible that the statements in the loop will never be executed. Working with For Next Loops 441 In contrast placing the condition at the end of the loop causes the test to be executed after the statements in the loop are executed. As a result the statements in the loop will always be executed at least once. Book V Chapter 2 Exiting a loop Many loops require an escape clause. s escape clause is the Exit For Exit While or Exit Do statement depending on the type of loop you want to get out of . When the program encounters one of these statements the loop ends immediately. Any remaining statements in the loop are ignored and the next .
đang nạp các trang xem trước