copyright 2008 Judith A Copeland - All About The Arrays By Judi Copeland
What is an Array Variables are memory pockets It stores information for a program A program can have many variables An array is simply a group of variables An array is a group of variables In a program, this allows data retrieved quickly
One Dimensional Array Arrays can be one dimensional These can be thought of as a list In this list, everything belongs to the same group Each item is numbered by subscript starting with 0
copyright 2008 Judith A Copeland - Two-Dimensional Arrays Arrays can also be two-dimensional These can be thought of more of a spreadsheet Similar topics that can be broken down Each topic has its own list Like one-dimensional arrays, they are also numbered starting from 0
copyright 2008 Judith A Copeland - One-Dimensional Format [Dim | Private] arrayName (highest numbersubscript) As datatype That could be replaced with Dim cake (5) As String Private birthdayCandles (10) As Decimal
copyright 2008 Judith A Copeland - Another One-D Example [Dim | Private] arrayName() As Datatype = {initialValues} That could be replaced with Dim cake () As String = {chocolate, vanilla, strawberry, banana, cherry, white} Private birthdayCandles () As Decimal = {1,5,10,12,18,21}
copyright 2008 Judith A Copeland - Two-Dimensional Format Since this version uses more than one group of lists, it differs [Dim | Private] arrayName (highestRowSubscript, highestColumnSubscript) As Datatype This pulls information from all of the columns involved This coordinates it with all the rows below each column
copyright 2008 Judith A Copeland - Example FrostingChocolate cake Vanilla cake Cherry cake Lemon cake chocolate SKU 1SKU 4SKU 7SKU 10 vanilla SKU 2SKU 5SKU 8SKU 11 Cream cheese SKU 3SKU 6SKU 9SKU 12 Cake inventory available – two categories, one for cake and the other for frosting
copyright 2008 Judith A Copeland - Using That Table in 2-D Dim cakeInventory (3, 2) As String There are 4 flavors of cake The first cake flavor is number 0 The last cake is number 3 There are 3 flavors of frosting The first frosting flavor is 0 The last frosting flavor is 2