Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter (3) - Looping Questions.

Similar presentations


Presentation on theme: "Chapter (3) - Looping Questions."— Presentation transcript:

1 Chapter (3) - Looping Questions

2 click Button1 Variable , Integer M 1 3 1 4 MsgBox(M)

3 To print the odd numbers from 5 to 9
But_Repeat click Dim (For … Next) Statement Me.Label1.text = Me.Label1.Text & m & vbCrLf Concatenate or append strings together MsgBox (m)

4 To Print the multiplication table of table 3 from 1 to 12 in separate lines inside textbox control.
True True False True True

5 5 11 7 7

6 Dim n , Product As Integer
Dim n , Product As String For n = 1 To Step 1 For n = 1 To Step -1 Product = 9 * n Product = n Next str Next n

7 Product Str Next m

8 I 1 B C TO Create new line between variables
To print the numbers from 1 to B and increased by C in separate lines inside textbox1 I 1 B C TO Create new line between variables

9

10 Comparison between Looping Statements
For …Next Statement Do …. While Statement It is one of the limited loop statements used when we want to repeat a code for specific number of time . It needs numeric variable (integer or decimal) to work as a counter with start value , end value and add or increment value . The statement 'Do while ... loop' is used to repeat a specific code for a several times of an unknown end, but based on a specific condition, so they are useful if you do not know the number of iterations emphatically. The repetitive code will be implemented (executed) as long as the counter variable is less than or equal the end value .The loop stops when the value of the counter exceeds the last value. The repetitive code will be implemented (executed) as long as the conditional expression is true. If the condition is not met for any reason, we get out of the iterative loop, and implement the code after the Loop if it exists. General syntax for this statement For Variable = Start To End Step Add Value Repetitive Code Next [Variable] Do While Conditional Expression Repetitive Code Loop

11 To increase the counter variable I by 2
Do … While To increase the counter variable I by 2 To print the odd or even no.`s from 1 to the entered no. Control Method property

12 To receive the value entered by the user in textbox1 and assign it to the variable N in computer memory. Do … While Statement The conditional expression (I <= N) is true TextBox1 N

13


Download ppt "Chapter (3) - Looping Questions."

Similar presentations


Ads by Google