Page 93 - Computer Class 08
P. 93

You will get following output.

             1.  Write any first number in this box.                               1

             2.  Write any second number in this                                   2
                   box.

             3.  Click on OK     button.                                             3

                  The result of the program will be
                   displayed here.





             Looping

             A loop is a series of one or more statements that execute more than one time. The loop
             statement  repeats  until  a  certain  predetermined  condition  is  met.  There  are  two  types  of
             Looping statements, DO WHILE & FOR NEXT. The Do-While is used when you do not know
             how many times to repeat the execution of the statements. Whereas in FOR-NEXT, when you
             repeat the number of times the statement is to be executed.
             First, we will discuss the DO-LOOP. This comes in several formats.

             1.     DO WHILE condition

                            Block of one or more Visual Basic statements
                    LOOP

             2.     DO
                            Block of one or more Visual Basic statements

                    LOOP WHILE condition
             3.     Do until condition

                            Block of one or more Visual Basic statements
                    LOOP

             4.     DO
                            Block of one or more Visual Basic statements

                    LOOP Until condition
             The  condition  in  each  Do  loop  is  any  expression  that  evaluates  to  true  or  false.  If  the
             condition is true, then the block of statements are executed, when it is false, the execution of

             DO-LOOP terminates.
             If the conditional test appears at the top and it fails, then the DO-LOOP may never execute
             for once also. If the condition is given at the end of the body, then atleast the DO-LOOP will
             be executed once.




                                                                                    Computer-8              93
   88   89   90   91   92   93   94   95   96   97   98