1 / 12

Arrays Part3

Arrays Part3. Objectives. Create and manipulate parallel one-dimensional arrays Create and initialize a two-dimensional array Store data in a two-dimensional array Search a two-dimensional array. Parallel One-Dimensional Arrays. Parallel arrays :

duane
Télécharger la présentation

Arrays Part3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arrays Part3

  2. Objectives • Create and manipulate parallel one-dimensional arrays • Create and initialize a two-dimensional array • Store data in a two-dimensional array • Search a two-dimensional array

  3. Parallel One-Dimensional Arrays • Parallel arrays: • Two or more arrays whose elements are related by their position in the arrays

  4. Parallel One-Dimensional Arrays (continued) • Hands-on Example

  5. Two-Dimensional Arrays • Two-dimensional array: • Resembles a table with rows and columns • Each element is identified by a unique combination of two subscripts: (row, column) • Subscripts are zero-relative

  6. Two-dimensional array: • Syntax: Form 1 [Dim|Private] arrayname(highestrowsubscript, highestcolumnsububscript) as dataytype Form 2 [Dim|Private] arrayname(, ) as dataytype= {{ initial values}…….{initialvalues}}

  7. Two-Dimensional Arrays (continued) • Hands-on Example

  8. Two-Dimensional Arrays (continued) • Two-dimensional array: • Declared with highest row subscript and highest column subscript (zero-relative) • Number of rows = highest row subscript + 1 • Number of columns = highest column subscript + 1 • Can specify initial values for array elements • If no initial values are declared, array elements are automatically initialized

  9. Storing Data in a Two-Dimensional Array • Hands-on Example

  10. Searching a Two-Dimensional Array • Hands-on Example

  11. Summary • Arrays: a group of related variables with the same name and same data type • Array element: one item in the array • One-dimensional array: each element is uniquely identified by its position (subscript) in the array • Two-dimensional array: each element is uniquely identified by its position (row and column subscripts) in the array • Subscripts are zero-relative

  12. Summary (continued) • Number of elements in an array is the highest subscript value + 1 • For Each...Next statement: used to loop through all the elements in an array • Length property: returns the number of elements in an array • Array.Sort method: sorts the elements in a one-dimensional array in ascending order • Array.Reverse method: reverses the order of elements in a one-dimensional array

More Related