CHAPTER 9 PART II. MULTIDIMENSIONAL ARRAYS Used to represent tables of values arranged in rows and columns. Table element requires two indexes: row and.

Slides:



Advertisements
Similar presentations
Arrays.
Advertisements

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.
AE6382 VBA - Excel l VBA is Visual Basic for Applications l The goal is to demonstrate how VBA can be used to leverage the power of Excel u VBA syntax.
Arrays Chapter 6. Outline Array Basics Arrays in Classes and Methods Sorting Arrays Multidimensional Arrays.
Arrays. What is an Array? An array is a way to structure multiple pieces of data of the same type and have them readily available for multiple operations.
 “Regular” variable ◦ Holds a single value ◦ For example Dim Student1 as String Dim Student2 as String Dim Student3 as String … Dim Studentn as String.
VBA Modules, Functions, Variables, and Constants
Case, Arrays, and Structures. Summary Slide  Case Structure –Select Case - Numeric Value Example 1 –Select Case - String Value Example  Arrays –Declaring.
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
1 Arrays  Arrays are objects that help us organize large amounts of information  Chapter 8 focuses on: array declaration and use passing arrays and array.
 2006 Pearson Education, Inc. All rights reserved Arrays.
Chapter 9: Arrays and Strings
Chapter 8 Arrays and Strings
Chapter 7: Working with Arrays
Arrays (Part II). Two- and Multidimensional Arrays Two-dimensional array: collection of a fixed number of components (of the same type) arranged in two.
Arrays Array of Controls: several controls, of the same type (Class: a prototype for an object indicating the properties and methods), that have the same.
 Pearson Education, Inc. All rights reserved Arrays.
VB .NET Programming Fundamentals
Java Unit 9: Arrays Declaring and Processing Arrays.
IE 212: Computational Methods for Industrial Engineering
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Using Arrays and File Handling
 2006 Pearson Education, Inc. All rights reserved Arrays.
Chapter 17: Arrays Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 8 Arrays and Strings
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.
© 2012 EMC Publishing, LLC Slide 1 Chapter 8 Arrays  Can store many of the same type of data together.  Allows a collection of related values to be stored.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
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.
Pemrograman Dasar Arrays PTIIK - UB. Arrays  An array is a container object that holds a fixed number of values of a single type.  The length of an.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
1 Chapter 7 – Arrays 7.1 Creating and Using Arrays 7.4 Two-Dimensional Arrays.
Arrays Group of variables that have a similar type
© 1999, by Que Education and Training, Chapter 8, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Variables,Constants and Data types Variables temporarily stores values during the execution of an application Variables have a name and data type Declare.
‘Tirgul’ # 3 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #3.
Chapter overview This chapter focuses on Array declaration and use Bounds checking and capacity Arrays storing object references Variable length parameter.
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.
Spreadsheet Models for Managers: Session 14 14/1 Copyright © Richard Brenner Spreadsheet Models for Managers Session 14 Using Macros II Function.
1 CS 106 Computing Fundamentals II Chapter 75 “Arrays” Herbert G. Mayer, PSU CS Status 7/31/2013 Initial content copied verbatim from CS 106 material developed.
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
6-1 Chapter 6 Working with Arrays in VB.NET. 6-2 Learning Objectives Understand the use of list and table arrays in VB.NET projects and the difference.
Visual Basic Programming I 56:150 Information System Design.
Arrays Chapter 8. Overview u General discussion u Variable arrays u Control arrays u Multi-dimensional variable arrays  Two-dimensional  Three-dimensional.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Arrays Chapter 7. MIS Object Oriented Systems Arrays UTD, SOM 2 Objectives Nature and purpose of an array Using arrays in Java programs Methods.
More on Variables and Subroutines. Introduction Discussion so far has dealt with self- contained subs. Subs can call other subs or functions. A module.
ILM Proprietary and Confidential -
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Visual Basic CDA College Paphos Campus COM123 Visual Programming 1 Lecture: Charalambous Sotiris Week 8: COM123 Visual Programming 1 Lecture: Charalambous.
Two-dimensional Arrays two-dimensional arrays are often used to represent tables of values consisting of data arranged in rows and columns (Fig. 7.16).
 2005 Pearson Education, Inc. All rights reserved Arrays.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
VBA - Excel VBA is Visual Basic for Applications
VBA - Excel VBA is Visual Basic for Applications
VBScript Session 2 Dani Vainstein.
7 Arrays.
Object Oriented Programming in java
Arrays.
VBScript Session 2 Dani Vainstein.
CIS16 Application Development and Programming using Visual Basic.net
7 Arrays.
EXCEL Creating An Array In VBA
Presentation transcript:

CHAPTER 9 PART II

MULTIDIMENSIONAL ARRAYS Used to represent tables of values arranged in rows and columns. Table element requires two indexes: row and column by convention. Two-dimensional: arrays that have two indexes to identify element. VBA supports at least 60 array dimensions generally use no more than 2 or 3.

MULTIDIMENSIONAL ARRAYS u(i,j) u = array name, i and j are indexes Example: Dim Sales(2,2) As Integer Option Base determines lower bound of each dimension Example: Dim tripleArray(50 to 100,8, 7 to 15) Ubound or Lbound could also be used The dimension is passed as second argument. If the dimension not provided, default dimension=1. Syntax error will occur if you reference a 2-dimensional array incorrectly.

MULTIDIMENSIONAL ARRAYS Example: For i = 1 To UBound(Array1) For j = To UBound(Array1,2) Column_Array( j ) = Column_Array( j ) + Array1( i, j ) Row_Array( i ) = Row_Array( i ) + Array1( i, j ) Next The Column_Array will contain column totals, while Row_Array will contain row totals. Common place to use For structure in array manipulations Access: 1-dimensional array use 1 For loop 2-dimensional array use 2 For loops

DYNAMIC ARRAYS Redimmable-grow and shrink at run-time Flexible and can be resized anytime Scope: Public (code modules), module, local Local dynamic arrays declared with Dim or Static allows efficient management of memory do not give size when declared Example: Dim dynamicArray() As Double Size is declared at run-time using ReDim Example: ReDim dynamicArray(9) (1) ten elements if Option Base = 0 (2) nine elements if Option Base = 1 Syntax errors: (1) attempting to use ReDim outside a procedure (2) attempting to use ReDim on fixed-size array ReDim can change index bounds Example: ReDim dynamicArray(50 to 100) changes lower bound from 0 to 50 total number of dimensions cannot be changed

DYNAMIC ARRAYS Example: cannot change 2-dimensional to 3- dimensional First ReDim sets number of dimensions Use sparingly since it will consume processor time ReDim executed: (1) sets all numeric values to zero (2) sets string to zero-length Preserve- saves values when ReDim is used

DYNAMIC ARRAYS Example: (retains original values) ReDim Preserve dynamicArray(50 To 150) Example: ReDim threeD(11,8,1) ReDim Preserve threeD(11,8,2) (change upperbound of 3 rd dimension from 1 to 2) Logic error: using ReDim without Preserve and assuming array still contains previous value Run-time errors: (1) attempting to change bounds for any dimension except last in a multidimensional array (using ReDim Preserve) (2) failure to Preserve array data can result in unexpected loss of data

DYNAMIC ARRAYS Deallocated (released) memory: Erase will release memory at run-time (1) array must be redimensioned with ReDim before use (2) Erase used with fixed sized arrays initialize elements to zero (3) run-time error: accessing a dynamic array that has been deallocated

VARIABLE-LENGTH ARGUMENTS: PARAMARRAY ParamArray- indicates a variable number of arguments are received Precedes declaration of Variant array Syntax error- declare variable in procedure header to right of ParmArray Syntax error: (2) declare a non-array variable with ParamArray (3) use ParamArray with an array type other than variant

FUNCTION ARRAY Creates and returns Variant array at execution time Values passed to array specify element values in returned array Returned array’s lower bound either 0 or 1 depending on Option Base ParamArray used to create Variant array