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.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

Excel and Visual Basic. Outline Data exchange between Excel and Visual Basic. Programming VB in Excel.
True BASIC Ch. 9 Practice Questions. What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT.
Algorithm & Flow Charts Decision Making and Looping Presented By Manesh T Course:1090 CS.
VB PROJECT “PROJECT SAMPLES”. For Next Loops Design a VB program that displays in a picture box the first N multiples of an input integer Input 3 exam.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Match-and-Stop Search Will find FIRST match Use Boolean variable to denote whether a match has been found or not Found initially False If a match is found,
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Introduction to Computing Dr. Nadeem A Khan. Lecture 23.
BACS 287 Programming Logic 3. BACS 287 Iteration Constructs Iteration constructs are used when you want to execute a segment of code several times. In.
Do Loop The syntax of DO loop: DO variable = initial_value, final_value[, increment] [statements] END DO Example: PROGRAM LINES ! Illustration of DO-loops.
Loops Counting down from N to 1 in assembly we used JUMP statements to repeat previous instructions thus looping READ LOOP: WRITE SUB decrement JPOSLOOP.
Chapter seven review Monther Aldwairi. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For.
Types of LOOP Structures Do While ……. Loop Do Until …… Loop For …… Next loop.
Introduction to Arrays Chapter 7 Why use arrays? To store & represent lists of homogeneous values To simplify program code To eliminate the need to reread.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
Chapter seven review. 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.
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter 6 - Visual Basic Schneider
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Introduction to Computing Dr. Nadeem A Khan. Lecture 8.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will –Learn about arrays One-dimensional arrays Two-dimensional arrays –Learn about searching.
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.
C#: Statements and Methods Based on slides by Joe Hummel.
Array Processing: Exercises School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 10, Friday 3/28/2003)
Review for Exam 2 School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 10, Friday 3/21/2003) - IF Blocks - Do Loops - Select.
Chapter 7 Code Tables. VB Code Box 7-1 Event Procedure for Compute Button Private Sub hsbExemptions_Change() txtExemptions.Text =Str(hsbExemptions.Value)
1 Shell Scripting (C shell) SungHo Maeung 10/27/2000 Tutorial section Computer Science Lab.
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
Chapter 6 - Visual Basic Schneider 1 Chapter 6 Repetition.
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.
Arrays. Variable Arrays a group of variables that have the same name and data type each element in a variable array is identified by a subscript refer.
Input and Output. Announcements  Exam Next Wednesday –Next Monday: Review session.  Invited talk: –7:30 PM,Tuesday, Oct 28th. –Prof. Katherine Socha.
Chapter 8 - Visual Basic Schneider
Count and add list of numbers From user input and from file.
Repetition Chapter 6 - Visual Basic Schneider 1  Loop Structure  Elements of a Loop Structure  Processing Lists of Data with Do Loops Chapter 6 -
Two Forms Please use speaker notes for additional information!
Repetition Structures
CSC 111. Solving Problems with Computers Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem.
VAT Calculator program Controls Properties Code Results.
Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter81 For....Next Loops n For i = m To n statement (s) Next i n For statement designates a numeric variable, called control variable. n It is initialized.
مقدمة في البرمجة Lecture 7. Write VB.net project using the for loop to calculate : 1- the sum of numbers from 1 to (A) numbers. 2- the sum of Odd numbers.
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.
L AB 4 July 5th. F OR LOOP Exercise 1: Find two ways of “Summing all 1, 2, and 3 digit prime numbers.” Use for loop Hint: isprime, primes.
情報基礎 A Lecture 12 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
Visual Basic - Break Processing
Processing multiple files
Multiplication
Multiplication
Chapter 7 Arrays.
Introduction to VB programming
Chapter 4 - Visual Basic Schneider
PROGRAMMING Program Development.
Visual Basic 6 Programming.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
Chapter 8 - Visual Basic Schneider
Repetition (While Loop) LAB 9
For...Next Statements.
Sub 範例 Sub F ( X ) MsgBox(X ^ 2 ) End Function
REPETITION Why Repetition?
Presentation transcript:

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 #1, a(i) Next i For i = 4 To 1 Step -2 picBox.Print a(i); Next i End Sub Contents of DATA.TXT: 1,3,5,7

Output: 7 3

What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(9) As integer Open "DATA.TXT" For Input As #1 do while not EOF(1) Input #1, x a(x) = x Loop For i = 4 To 9 sum = sum + a(i); Next i Print sum End Sub Contents of DATA.TXT: 1,5,3,7

Output: 12

What is the output of: Dim a(2 To 9) As Integer, i As Integer, _ k As Integer, sum As Integer For i = 2 To 9 a(i) = i Next i sum = 0 For k = 4 To 6 sum = sum + 10 ^ a(k-2) Next k picBox.Print sum

Output:

Private Sub cmdButton_Click() On Error GoTo ErrorHandler Dim Q(2 To 7) As Integer p = 4 k = (p + p) / Q(p) Print p + k Exit Sub ErrorHandler: Q(p) = 2 p = Q(p) Q(p) = 2 Resume End sub

Output: 4

What is the output of: Dim a(-1 to 5) As Single, x As Single Open "DATA.TXT" For Input As #1 Do While Not EOF(1) Input #1, x a(x) = a(x) + 3 Loop Close #1 picBox.Cls picBox.Print a(0); a(2) Contents of DATA.TXT: 0, 1, 5, 2, 0

Output: 6 2

Dim a(-2 To 5), b As Integer Dim i As Integer, j As Integer Open "DATA.TXT" For Input As #1 num = 0 For i = 3 To 5 Input #1, a(i) Next i For j = -1 To 1 Input #1, k b = b + a(k) Next j picBox.Print b Contents of DATA.TXT: 2, 1, 0, -1, 3, 3

Output: 4