vb-arrays - CIS 338: VB.NET Arrays Dr. Ralph D. Westfall...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 338: VB.NET Arrays Dr. Ralph D. Westfall April, 2009
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
General Programming Tasks data processing can be handled by sequence – one line after another selection – running this or that code looping – doing same thing over and over data can be stored as variables – one value per variable name collections – groups of related items
Background image of page 2
Array an array is an object it contains multiple values all of the values are of the same data type primitive or object types all the values share the name of the array but they are also identified by an index has a fixed length, set when it is created
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Array only need one variable name to store many different "elements" student(0) . .. student(19) variable name followed by (index) index starts at 0 (zero based) in VB.NET, use parentheses instead of Java's square brackets around the index index must be an Integer or a variable that evaluates to an Integer
Background image of page 4
Array Subscripts items in an array are identified by an index number or "subscript" Dim monthNames( 11 ) as String monthNames ( 0 ) = "January" monthNames ( 11 ) = "December" subscript starts at 0, and goes to the "upper bound" of the array (track laps) loop counter variables can be subscripts
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Array Subscripts - 2 can use variables for subscripts, or even calculate the subscripts Dim i as Integer = 0 txtMonth.Text = month(i) txtMonthPlus2.Text = month(i + 2) subscript variables (or calculated values) must be integers, and must be within the range of the index
Background image of page 6
Array Memory Locations whole array and first element have the same address address of each element is this address plus the index times the number of bytes for an element day(0) address = address of day array plus 0 * 4 (Integer stored in four bytes) day(9) = day array address + 9 * 4
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if don't specify size, can put parentheses in either of 2 positions
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/13/2009 for the course CIS 338 taught by Professor Westfall during the Winter '09 term at Cal Poly Pomona.

Page1 / 30

vb-arrays - CIS 338: VB.NET Arrays Dr. Ralph D. Westfall...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online