VB NOTES PART 12 - ---Array elements can be any data type...

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

View Full Document Right Arrow Icon
3/8 ---Arrays Dim myArray As Integer () Declares array, but doesn’t give it assize Arrays are objects, so (New will create an object) MyArray= New Integer (12 ) {} -----------------one-dimensional array (line, list) Equivalent to 0 To 12--------allocates 13 spots indexed from 0 To 12 Dim myArray (0 To 12) As Integer Now, elements can be accessed by their index (subscript) (Indices are offsets ; how many elements to skip) myArray (3) = 7 MyArray(0) 4 MyArray(1) 8 4 MyArray(2) 15 3 16 7 Subscripts can be expressions (anything evaluates to an integer) Dim x As Integer =2 MyArray (2*x-3) =4 ------------myArray (1) = 4
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ---Array elements can be any data type For primitive type, array element holds the value For objects, array element holds a reference -------------refers to an object---initializing myArray = New Integer () {4, 8, 15, 16 } Initialize list Dim strArray As String () = New String () {hello, there}---uninitilialized elements: Integer: 0 Double: 0.0 Boolean: False Reference: Nothing To get largest index: MyArray. GetUpperBound (0 ) Method which dimension For counter As Integer = 0 To myArray. GetUpperBound (0) MyArray (counter) =3] Next MyArray(0) 3 MyArray(1) 3 MyArray(2) 3 3 3...
View Full Document

This note was uploaded on 12/01/2011 for the course 6K 226 taught by Professor Staff during the Fall '10 term at University of Iowa.

Page1 / 2

VB NOTES PART 12 - ---Array elements can be any data type...

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

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