|
Loops -------------- I know, everyone loves loops right? Well in VB, they're not as hard as you think they are. I grouped each line into a table so its easier to understand. Ok a loop is steup in this way: For * As Integer = * to * [ Statements ] Next
For This initiates the loop. ---- * As Integer The first star is the variable name. This loop only works for integers. Because yuou cant loop through a sting like this. (Eg. myVar as Integer) ---- = * to * Then you set your variable to some value. (eg. 1 to 10 (for integer)) |
Statements
Statements are what you want your loop to do. So if I have a listbox on my form, And want to loop through my numbers and add them to the listbox, I'd do it this way: | For i as integer = 1 to 10 'set i as integer and equal to 1 through 10 Listbox1.Items.Add (i) Next |
------------------------- Next
All "Next" does is close the loop and then repeat to the top. And then loops. The loop. -------------------------------------------------- |
That is on a "For Next" loop. There are other loops. Such as "Do While" loops, "Do Until" Loops, but this is a general idea. And if you have any questions post here or send me a PM. If you want to do any Visual Basic, you know making Windows applications or whatnot, go downwload Visual Basic Express Edition from Microsoft. Any questions, PM me.
|
|
|
|