CSC 162 Visual Basic I Programming. Array Parameters and Sorting Array Parameters –Entire Arrays –Individual Elements Sorting –Bubble Sort.

Slides:



Advertisements
Similar presentations
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Advertisements

One Dimensional Arrays
Chapter 2.9 Sorting Arrays. Sort Algorithms A set of records is given Each record is identified by a certain key One wants to sort the records according.
Analysis of Algorithms CS Data Structures Section 2.6.
Modeling using VBA. Covered materials -Userforms -Controls -Module -Procedures & Functions -Variables -Scope.
Pemrograman VisualMinggu …7… Page 1 MINGGU Ke Tujuh Pemrograman Visual Pokok Bahasan: Arrays Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
Computer Science 112 Fundamentals of Programming II Bucket Sort: An O(N) Sort Algorithm.
Aalborg Media Lab 2-May-15 Exercises/Summary Lecture 10 Summary, Exercises.
1 5.3 Sub Procedures, Part II Passing by Value Passing by Reference Sub Procedures that Return a Single Value Debugging.
Sorting. Sorting Considerations We consider sorting a list of records, either into ascending or descending order, based upon the value of some field of.
COPYRIGHT 2003: Dr. David Scanlan, CSUS OBJECTIVES: Explain the need for arrays. Coding an array. Basic algorithms: Largest, Smallest, Sum, Standard Deviation,
1 Visual Basic Programming II Lecture 3 MIS233 Instructor – Larry Langellier.
Lecture Roger Sutton CO331 Visual Programming 12: One-dimensional Arrays 1.
Control Arrays. All the components in the Visual Basic toolbox are referred to as controls A control array is a group of controls of the same type that.
Binary Search Visualization i j.
Chapter 11 Sorting and Searching. Topics Searching –Linear –Binary Sorting –Selection Sort –Bubble Sort.
PSU CS 106 Computing Fundamentals II VB Subprograms & Functions HM 4/29/2008.
Passing Arrays to Procedures: ByVal vs. ByRef. Passing Arrays to Procedures Passing the Array – Specify the name of the array without using parentheses.
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.
Ordered Arrays An array is ordered if the elements are in ascending or descending order. The array may be ordered numerically or alphabetically (which.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic concepts and uses of arrays ❏ To be able to define C.
ISAT 252 Introduction to Arrays. Should have read 2 Chapter 8 –pp , and pp
Ch 10: More on Variables and Subroutines CP212 Winter 2012.
IE 212: Computational Methods for Industrial Engineering
1 Microsoft Visual Basic 2010 Arrays. 2 Using a One-Dimensional Array Lesson A Objectives After completing this lesson, you will be able to:  Declare.
Visual Basic I Programming
COMP102 Lab 131 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
Chapter 17: Arrays Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
CSC 162 Visual Basic I Programming. Randomizing and Formatting Randomizing Formatting –User-Defined Formats –Named Numeric Formats.
CSCI Chapter 8 Arrays Instructor: Bindra Shrestha University of Houston – Clear Lake.
Week Arrays, Timers, and More 9. 2 Introduction Arrays are like groups of variables that allow you to store sets of similar data A single dimension array.
Arrays and 2D Arrays.  A Variable Array stores a set of variables that each have the same name and are all of the same type.  Member/Element – variable.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
# 1# 1 Searching andSorting What is selection sort? What is bubble sort? What is binary search? CS 105 Spring 2010.
© 1999, by Que Education and Training, Chapter 8, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Arrays Chapter 8. Chapter 8 - Part 12 Variable and Variable Array Variable Stores only one value Variable Array Variable that has 1 symbolic name but.
‘Tirgul’ # 3 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #3.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab9 Control Array Print Method Printing VB Output.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
1 Topic: Array Topic: Array. 2 Arrays Arrays In this chapter, we will : Learn about arrays Learn about arrays Explore how to declare and manipulate data.
Arrays. Lesson Objectives  To understand what an array is and it’s function  To know how code and array in VB.
An Introduction to Programming with C++ Fifth Edition Chapter 11 Arrays.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Copyright © 2001 by Wiley. All rights reserved. Chapter 6: Using Arrays Control Arrays List Arrays Finding Items in Arrays Multiple Forms 2-Dimensional.
Chapter 71 Arrays Creating and Accessing Arrays Using Arrays Some Additional Types of Arrays.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley More About Array Processing 8.2 There Are Many Uses of Arrays and Many Programming.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
1 CSC103: Introduction to Computer and Programming Lecture No 19.
Bubble Sort Notes David Beard CIS220. Bubble Sort for Strings Double pass algorithm to sort a single dimensional array. Inner loop “bubbles” largest element.
Programming games in Visual Basic Review programming & VB topics Insertion sort. Best times. Generate questions & answer patterns for quiz Lab/Homework:
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
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.
Tutorial 81 Field, Record, Data File Field - a single item of information about a person, place, or thing Record - a group of related fields that contain.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
Copyright © 2014 Pearson Education, Inc. Chapter 6 Procedures and Functions.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Assignment 5 is posted. Exercise 8 is very similar to what you will be doing with assignment 5. Exam.
7.1 Introduction Arrays Arrays are data structures consisting of data items of the same type “Static” entities They remain the same size once they are.
Sorting.
Visual Basic I Programming
Fundamentals of Programming II Bucket Sort: An O(N) Sort Algorithm
Dr. Ralph D. Westfall June, 2011
Chapter 8 Arrays Objectives
Chapter 7 Arrays.
Lbound and Ubound Functions
Chapter 8 Arrays Objectives
Procedures and Functions
Chapter 8 Arrays Objectives
Instructions For the workshop, the intent is to have each participant get one piece of paper, printed front and back. Each page should have an “a” side.
Presentation transcript:

CSC 162 Visual Basic I Programming

Array Parameters and Sorting Array Parameters –Entire Arrays –Individual Elements Sorting –Bubble Sort

Array Parameters When arrays are passed to procedures, they must be passed ByRef. –Visual Basic makes this a requirement since copying large arrays could take up too much room in memory.

Array Parameters Array parameters are not specified with a size, since they are passed ByRef. Private Sub PrintNums(ByRef intNums() As Integer) Dim intCounter As Integer For intCounter = LBound(intNums) To UBound(intNums) Print intNums(intCounter) Next intCounter End Sub

Array Parameters When arrays are passed into a procedure, the size is also not specified, since they are passed ByRef. Dim intValues(1 To 100) As Integer. Call PrintNums(intValues())

Array Parameters However, individual elements of the array are passed just like any single value. Private Sub PrintValue(ByVal intValue As Integer) Print "The selected value is " & intValue End Sub Dim intNumbers(1 To 50) As Integer. Call PrintValue(intNumbers(20))

Bubble Sort Arrays can be sorted in two ways: –Ascending (1  100, A  Z, etc.) –Descending (100  1, Z  A, etc.) Array functions: –Starting index (lower bound): LBound() –Ending index (upper bound): UBound()

Lab Assignment Write a program that will do the following: 1.Put 20 random (integer) numbers with a range of 1 to 100 into an array of size Sort the array in descending order.* 3.Display the entire sorted array in a ListBox. * Use the Bubble Sort algorithm, but put it into a sub procedure called DescendingSort. Programming Assignment 5 Due Monday, November 10 / Tuesday, November 11 Page 241 #6.18 Page 241 #6.19