Tutorial 9 Slides
Download
Report
Transcript Tutorial 9 Slides
Tutorial 9
Introducing Do While & Do
Until Loops & Repetition
Statements
Do While Loop
Do While [condition]
action(s)
Loop
intCounter = 0
Do While (intCounter < 10)
intSumOfNumbersUpto10 += intCounter
intCounter += 1
Loop
Continue
Repeats the actions as long as the
condition is true
The condition must change, otherwise
infinite loop will occur.
Within the loop add code(s) to change the
condition that eventually become false
Do Until Loop
Do Until [condition]
action(s)
Loop
intCounter = 0
Do Until (intCounter >= 10)
intSumOfNumbersUpto10 += intCounter
intCounter += 1
Loop
Continue
Repeats the actions as long as the
condition is false
The condition must change, otherwise
infinite loop will occur.
Within the loop add code(s) to change the
condition that eventually become true
Coding with ListBox
Remove items in the ListBox
lstStudents.Items.Clear( )
Class.SubClass.Behavior
or
Add items to the ListBox
lstStudents.Items.Add (“Name” &
ControlChars.Tab & ControlChars.Tab &
“Course”)
Example
Dim intCounter As Integer = 1
Dim intSumOfNumbersUpto10 As Integer = 0
Do While (intCounter < 10)
intSumOfNumbersUpto10 += intCounter
lstNumbersUpto10.Items.Add(“Number “ &
intCounter & ControlChars.Tab &
intSumOfNumbersUpto10)
intCounter += 1
Loop