


Exit For is similar to “Exit Do” which can be used to come out of the For block and execute the statement that follows.The step can be used to increment or decrement the counter value.The step clause if not specified, the for loop steps one counter forward by default.As you can see from the syntax above, there is a “Step” clause to this statement.This is the statement that you would use when you want a statement/set of statements to run a certain number of times while a certain counter gets incremented or decremented. It is self-explanatory from the syntax that the statements nestled under the while block get executed as long as the condition holds true.Īlthough this statement is available, it is not very flexible, hence it is recommended to use the Do…Loop statement. Exit Do is a statement that is used in such circumstances. In the case of syntax 1, the statements within the do loop do not get executed unless the condition becomes true or holds true.įor syntax 2, the statements within the loop get executed at least once, and then the check is performed on the condition.Įxit Do: In order to avoid infinite loops we will have to force the loop to exit. There is also a slight difference between syntax 1 and syntax 2. If the condition is null it is treated as False. This is used when a statement or a block of statements needs to be executed while or until a said condition is true.Ĭondition: Could be a numeric or string component that either attains a true or false value.
#CLICLICK LOOP SCRIPT CODE#
The condition is evaluated once and based on the value it attains, one of the following blocks of code gets chosen to be run. This is to choose one out of the many options depending on the condition that comes satisfied. Elseif is another variation that can be used while choosing one of the multiple options.Alternately, the else block can be used or not.The if.then.else statements can be nested to any number of levels.This is the typical syntax to write this statement. Best Practices for Code Writing in VB Script.
