ISYS-302: Programming in Visual Basic: Class Notes for Session 6
Loops and Lists
Loop that will not execute You cannot count from 6 to 1, that is going backwards, so the loop will do nothing. ---------------------- for i = 6 to 1 MsgBox "Count:" & i next i ---------------------- To correct this loop: ---------------------- for i = 6 to 1 Step -1 MsgBox "Count:" & i next i ---------------------- Loop will now display 6...5...4...3...2...1. If the first number is greater than the second (i.e. 6>1) and there is no step -1 (or step -2,etc) then the loop will not execute.
Examples
Assignment
Start with Class6ExampleB. Implement the remove method so that student scores can be removed. Also implement the Get Avg button so that the average score of all students is shown in a MsgBox.
