We did some quick questions (here they are without answers
in case you want to try them again, with answers at the bottom of the post so you can check them), then we had a look at how to make code repeat itself a set number of times. One way to do this is with a for loop.
In Visual Basic you need a counter (to keep track of how often the loop has gone round). This can then be used to do clever things, like change a particular element of an array. For example in the code below on the tenth go around of the loop, what the user types in will go into place 10 of the array (if you are starting from 1):
For counter := 1 to 15
name(counter) = InputBox(“Please type in another name”)
Next
If you still don’t get it, re-read the powerpoint below:
And these are the answers to the quick questions:
November 19, 2007 at 3:43 am |
for each loops technically have counters, but the count is implied by the object being referenced.
for each dr as datarow in datagridview
next