Visual Basic.net Loops
Used to do multiple executions of the same block of code Do while loops Do until loops For next loops
Do while loop (Syntax) Do while (condition) [loop instructions] Loop
Do while loop (example) Dim intCount as Integer ‘ declare local variable Intcount = 1 ‘ initialing counter to 1 Do while intCount <= 3 ‘ loop while count is <= 3 Print intCount ‘ print intCount to the printer intCount = intCount + 1 ‘ add 1 to intCount Loop ‘ redo the block of code until false
Do while (Flowchart) Start Declare intCount variable intCount = 1 intCount <= 3 Stop Display intCount intCount = intCount + 1 T
Do until loop (Syntax) Do [loop instructions] Loop until (condition)
Do until (example) Dim intCount as Integer ‘ declare a local variable intCount = 1 ‘ initializing counter to 1 Do ‘ redo block of code until false Print intCount ‘ print intCount to the printer intCount = intCount + 1 ‘ add 1 to intCount Loop until intCount > 3 ‘ loop until > 3
Do until (Flowchart) Start Declare intCount variable intCount = 1 Display intCount intCount = intCount + 1 intCount > 3 Stop T F
For Next Loop AKA an automatic counter loop Repeats a block of code statements a specified number of times
For Next (Syntax) For counter = startvalue to endvalue [Step stepvalue] [instructions] Next counter
For Next (Example) For intCount = 1 to 3 Step 1 ‘ initializing Print intCount ‘ prints out intCount Next intCount‘ loop
For Next (Flowchart) Start Declare intCount variable For for next loop Print intCount Stop 1 >3 intCount 1