Visual Basic.net Loops Loops • Used to do multiple executions of the same block of code • Do while loops • Do until loops • For next loops Do.
Download ReportTranscript Visual Basic.net Loops Loops • Used to do multiple executions of the same block of code • Do while loops • Do until loops • For next loops Do.
Visual Basic.net Loops 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 T Display intCount intCount = intCount + 1 Stop 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 T F intCount > 3 Stop 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 intCount >3 1 1 Print intCount Stop