Page 149 - Open Soource Technologies 304.indd
P. 149

Unit 6: VB Control Structure





                                                              Set
                                                          control variable
                                                           ti initial value

                                    For i = m to n
                                       Processing steps (s)
                                    Next
                                                               Is     Yes
                                                          control variable
                                                           > terminating
                                                             value?
                                                                 No

                                                            Execute
                                                           statements
                                                            within loop


                                                             Increment
                                                              control
                                                             variable




                                                             Execute
                                                            statements
                                                             following
                                                             the loop
                                Figure 6.4:  Pseudocode and Flowchart of a For Next Loop.
               The control variable can be any numeric variable. The most common single-letter names are i,
               j, and k; however, if appropriate, the name should suggest the purpose of the control variable.

                              1: Suppose the population of a city is 300,000 in the year 2006 and is growing
                                at the rate of three percent per year. The following program displays a table
                                showing the population each year until 2010.
























                                      LOVELY PROFESSIONAL UNIVERSITY                        143
   144   145   146   147   148   149   150   151   152   153   154