可能存在需要多次執行代碼塊的情況。一般來說,語句是按順序執行的:首先執行函數中的第一條語句,然後執行第二條語句,依此類推。
程式語言提供各種控制結構,允許更複雜的執行路徑。loop語句允許我們多次執行一個或一組語句,下面是VBScript中loop語句的常規from。
VBScript提供以下類型的循環來處理循環需求。單擊以下連結以檢查其詳細信息。
Loop Type | Description |
---|---|
for loop | Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. |
for ..each loop | It is executed if there is at least one element in group and reiterated for each element in a group. |
while..wend loop | It tests the condition before executing the loop body. |
do..while loops | The do..While statements will be executed as long as condition is True.(i.e.,) The Loop should be repeated till the condition is False. |
do..until loops | The do..Until statements will be executed as long as condition is False.(i.e.,) The Loop should be repeated till the condition is True. |
Loop Control Statements
循環控制語句改變其正常順序的執行。當執行離開作用域時,循環中的所有剩餘語句都不會執行。
VBScript支持以下控制語句。單擊以下連結以檢查其詳細信息。