Thursday, May 14, 2009

Exiting the Loop

sometime we need exit to exit a loop prematurely because of a certain condition is fulfilled. The syntax to use is known as Exit Do. You can examine Example 9.2 for its usage.

For....Next Loop

The format is:


For counter=startNumber to endNumber (Step increment)

One or more VB statements

Next


Please refer to example 9.3a,9.3b and 9.3 c for its usage.

Sometimes the user might want to get out from the loop before the whole repetitive process is executed, the command to use is Exit For. To exit a For….Next Loop, you can place the Exit For statement within the loop; and it is normally used together with the If…..Then… statement. Let’s examine example

No comments:

Post a Comment