For…Next : Nested Loop X= 0 For i = 0 To 4 For j = 0 To i-1 X=X+(i+j-1) Next j Next i How many times the inner loop is executed? What is x at the end of.

Slides:



Advertisements
Similar presentations
Converting Numbers Between Bases. While the quotient is not zero…  Divide the decimal number by the new base.  Make the remainder the next digit to.
Advertisements

IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
Introduction to Computing Dr. Nadeem A Khan. Lecture 21.
Introduction to Computing Dr. Nadeem A Khan. Lecture 23.
Introduction to Computing Dr. Nadeem A Khan. Lecture 22.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
Introduction to Computing Dr. Nadeem A Khan. Lecture 27.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Introduction to Computing Dr. Nadeem A Khan. Lecture
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Introduction to Computing Dr. Nadeem A Khan. Lecture 7.
BACS 287 Programming Fundamentals 4. BACS 287 Programming Fundamentals This lecture introduces the following iteration control structure topics: – Do.
Visual Basic Statements
Monday, 11/18/02, Slide #1 CS 106 Intro to CS 1 Monday, 11/18/02  QUESTIONS??  Today:  Hand back, discuss HW #4  Discussion of Lab 10  Exam #2 Friday.
1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Chapter 6 - Visual Basic Schneider
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
Arrays. What is an Array? Similar to a Matrix. Collection of data that needs similar processing. Example: Transpose of a matrix.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 Principles of Software Design and Development LOOPS / REPITITION.
Sentinel Logic Assumes while loops and input statements.
5.05 Apply Looping Structures
Created By Mayson Al-Duwais1. Using Exit to Terminate Repetition Statements To terminate different types of repetition statements you can use a special.
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
ENGR 112 Decision Structures.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Repetition Chapter 7. Overview u For Loop u Do Loop  Do While Loop  Do Until Loop  Do Loop While  Do Loop Until u Nested Loops.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Visual Basic CODE. Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment.
ISAT 252 Visual Basic Repetition. Assignment Should have read Chapter 5 ( ) on loops Do tutorial 5-4.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Chapter 6 - Visual Basic Schneider 1 Chapter 6 Repetition.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
Chapter 71 Repetition - Do Loops n A Loops, is used to repeat a sequence of statements a number of time n There are two loops commands in Visual Basic.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
1 Chapter 10 Additional Control Structures and Exceptions.
Overview of VBA Programming & Syntax. Programming With Objects u Objects –Properties: attributes or characteristics of an object (e.g., font size, color,
259 Lecture 11 Spring 2013 Advanced Excel Topics – Loops.
Repetition Structures
Looping Structures Do Loops, For Next Do...Loop While structures check the condition after executing the code and repeat a code block until the test.
For…Next Loops, Checked List Boxes, and Combo Boxes Chapter 5.
Higher Computing Software Development -So Far- 5/10/10.
Introduction to Computing Dr. Nadeem A Khan. Lecture 9.
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Loop and repetition. Today Passing values to and back from Sub procedures Option Buttons Do While Loops For Loops Population Growth.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Two-Dimensional Arrays. Two-dimensional arrays variables store the contents of tables or matrices. Example: Dim arrTable(1 to 5, 1 to 5) As Integer first.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
MIC305 Week 6 Beyond controls Review of properties Differences with VB6: using classes and instances Programming constructs.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
Processing multiple files
UNIT 5 Lesson 15 Looping.
Advanced Excel Topics – Loops
Visual Basic 6 (VB6) Data Types, And Operators
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
حلقات التكرار.
Case & Repetitive Statements
Prepared By: Deborah Becker
For...Next Statements.
Converting Numbers Between Bases
Presentation transcript:

For…Next : Nested Loop X= 0 For i = 0 To 4 For j = 0 To i-1 X=X+(i+j-1) Next j Next i How many times the inner loop is executed? What is x at the end of this loop?

Nested For…Next : Execution i=0 j=0  -1 i=1 j=0  0 i=2 j=0  1 i=3 j=0  2 i=4 j=0  3 No. of times inner loop is executed x

For…Next : Exit X= 0 For i = 0 To 4 For j = 0 To i-1 If x > 5 Then Exit For End If x=x+(i+j-1) Next j Next I Exit from the inner loop

Do…Loop Do While logical expression Executable statement(s) Loop Do Executable statement(s) Loop Until logical expression

Do While…Loop

Do…Loop Until…

Do Loops Sum = 0 Kount = 0 Do While Kount <= 10 Sum = Sum + Kount Kount = Kount + 1 Loop Sum = 55 Kount = 11 Sum = 0 Kount = 0 Do Sum = Sum + Kount Kount = Kount + 1 Loop Until Kount > 10 Sum = 55 Kount = 11

Decimal to Binary : Do While Private Sub Command1_Click() Dim Deci As Integer Dim R As Byte, Bin As String Deci = Text1.Text Bin = "" Picture1.Cls If Deci = 0 Then Bin = Str(Deci) End If Do While Deci > 0 R = Deci Mod 2 Bin = Str(R) + Bin Deci = Deci \ 2 Loop Picture1.Print Bin End Sub

Decimal To Binary: Do…Until Private Sub Command3_Click() Dim Deci As Integer Dim R As Byte, Bin As String Deci = Text1.Text Bin = "" Picture1.Cls Do R = Deci Mod 2 Bin = Str(R) + Bin Deci = Deci \ 2 Loop Until Deci = 0 Picture1.Print Bin End Sub

File Handling  Files are used for large data input/output  Create a.txt file called CarData by using Notepad (or ASCII file using other software) with following contents “Suzuki”, 3, 4 “Toyota”, 5, 7 “Honda”, 4, 15

File Handling  Files must be Open ed before any read/write operation.  Files must be Close d after any read/write operation  Syntax Open “CarData” For Input As #138  Opens a file called CarData.txt for read- only and this file will be called #138  The file reference number can be from 1 to 255