CSE 100: Lab, May 6

Array Variables and Indexing

See also: May 5 lecture, "Indexing: Just More Of The Same"


keep this picture in mind

some key points

array vocabulary

What's up with these?

Each of these lines has a syntax error, i.e. a mistake in usage of the above array. What's wrong?

If authorArray(7) = "Naipaul" Then ...

authorArray("two") = "Melville"

MsgBox "Read any " & authorArray & " lately?"

Case Select authorArray(1.5) ...








looping through arrays

With what you know about arrays, what do you think this Sub does with the above array?

Sub pesterMeAboutReading()
  Dim i As Integer

  For i = 0 to 5
    MsgBox "Go read some " & authorArray(i) & "!"
  Next i
End Sub
Note that authorArray must be declared as a global array for this work.


Ken Yasuhara <yasuhara@cs.washington.edu>
Last modified: Fri May 7 02:29:39 PDT 1999