Presentation is loading. Please wait.

Presentation is loading. Please wait.

Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6)

Similar presentations


Presentation on theme: "Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6)"— Presentation transcript:

1

2 Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6) lstTest.Items.Add(7) lstTest.Items.Add(8) lstTest.Items.Add(9) lstTest.Items.Add(10)

3 S.C.O.R.E Sequence your tasks Choose your options Once may not be enough Recycle and reuse Evaluate and improve

4 Types of Loops Type 1For Next Loop LogicRepeats a section of code a specified number of times. So if we wanted to do a task 1000 times, this kind of loop is ideal. Type 2While Loop LogicRepeats a section of code until a certain condition is met, that is the condition may be met on the first attempt or on the thousandth, we simply don’t know! For example we might want to delete all inactive members of a video club so long as there are any left to delete. Type 3Do Loop LogicRepeats the code once then continues until a certain condition is met. For example a student may study one or more modules and each module needs a start date. Since a student must have at least one module we are guaranteed to do at least one item of processing, but we don’t know how many modules a student is studying so the loop will end only when all modules are processed.

5 The For Next Loop For any loop to work we need to know three things… When the loop will start When the loop will end Where the loop is up to at a given point

6 The Load Event

7 DisplayWishList

8 Step For Counter = 1 to 5 Step 2 'code here Next Would loop three times, through the values 1, 3 and 5. Step forces the loop (in this example) to make increments of 2. What does the following code do?... For Counter = 5 to 1 Step -1 'code here Next

9 Questions 1. Complete the code for the following For Next loop so that it starts with a value of 1 and ends with 10: Dim Counter as Integer For Counter = _____ To _____ 'code here Next

10 Questions 2. What will be the value of Temp? Dim StartValue As Integer Dim EndValue As Integer Dim Counter As Integer Dim Temp As Integer StartValue = 10 EndValue = StartValue * 2 Temp = 0 For Counter = StartValue To EndValue Temp = Temp + 1 Next

11 Questions 3. Write a For Next Loop that counts from 50 to 200. 4. Write a For Next Loop that counts from 10 to 0 in steps of 2.


Download ppt "Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6)"

Similar presentations


Ads by Google