advertisement

csa computer4 lesson3

50 %
50 %
advertisement
Information about csa computer4 lesson3
Education

Published on July 19, 2008

Author: sdreyes102877

Source: authorstream.com

advertisement

OBJECTIVES Students should be able to: : OBJECTIVES Students should be able to: describe the logic of a looping statement in a program. create a loop program using the correct syntax. demonstrate series of commands through few lines of codes or instructions. 2 What is a LOOPING Statement? : What is a LOOPING Statement? Looping is a repeated group/s of instructions. It allow us to repeat statement or series of statements a number of times using very few lines of instructions. Visual Basic has three special structures for managing loops. (1) For…Next (2) While…Wend (3) Do…While 3 Syntax: : Syntax: Dim <Variable> ‘ optional For <Counter Variable> = <Initial Value> to <Ending Value> <Instructions> Next <Counter Variable> Private Sub Command1_Click() For i = 1 to 10 Print "programmershelp" Next i End Sub 4 For/Next with STEP Clause : For/Next with STEP Clause Step may result to INCREMENT or DECREMENT of the process. Example: Private Sub Form_Activate() Dim num As Integer For num = 2 To 10 Step 2 Print num Next num End Sub 5 Illustrating a CIRCLE using a LOOP : Illustrating a CIRCLE using a LOOP Private Sub Command1_Click() For i = 1 To 1000 Step 20 Circle (1000, 1000), i Next i End Sub 6 Exponentiation Table : Exponentiation Table Private Sub Form_Activate() Dim num As Integer, power As Long For num = 1 To 10 power = 5 ^ num 'raised 5 to power that follows Print 5; "^"; num; "="; power Next num End Sub 7 DRILL: : DRILL: Write the complete codes of the given INTERFACE below. 8 CORRECT ANSWER: : CORRECT ANSWER: Private Sub Form_Activate() Dim num As Integer, mult As Long For num = 1 To 10 mult = 5 * num Print 5; " * "; num; "="; mult Next num End Sub 9 Activity 4 JULY 7 – 11, 2008 : Activity 4 JULY 7 – 11, 2008 Demonstrate your QUIZ#4 program via HANDS ON. Use the filename: YOURLASTNAME_looping for both form and project files. You have 20 minutes encoding and designing time. Checking will be done before the period ends, No extension!!! RUBRIC: 20 – Running w/ No error 15 – Running w/ Minor errors 10 – Not running w/ loads of errors 00 – No Output  "Our lives improve only when we take chances, and the first and most difficult risk we can take is to be HONEST with ourselves.“ Walter Anderson God Bless!!! 10 QUIZ 4 JULY 7 – 8, 2008 : QUIZ 4 JULY 7 – 8, 2008 Write the complete codes of the given INTERFACE below. Apply Conditional – If/then/Else and Loop- For/Next Statements in your codes.  "Our lives improve only when we take chances…and the first and most difficult risk we can take is to be HONEST with ourselves.“ Walter Anderson God Bless!!! Please use your Name & your Section Employ NUMBER as your variable. SAMPLE CODE: Private Sub Form_Activate() Dim number As Integer For number = 1 To 10 Print number Next number End Sub Quiz #4: Answer : Quiz #4: Answer Private Sub Command1_Click() Print "REYES, Sheree Ann D." Print "IV-St. Monica" Print Dim number As Integer For number = 1 To 10 If number = 4 Then Print "This is number 4" Else Print number End If Next number End Sub 1 point 2 points / line 1 point (24 + 1) = 25 TOTAL POINTS >>>

Add a comment

Related presentations