19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

txtFinal.Text = “”<br />

picGrades.Print “Student added.”<br />

End Sub<br />

Private Sub cmdSemGrade_Click()<br />

Dim i As Integer, grade As String<br />

picGrades.Cls<br />

For i = 1 To section.Count<br />

picGrades.Print section.Item(i).Name; _<br />

Tab(28); section.Item(i).SocSecNum(); _<br />

Tab(48); section.Item(i).SemGrade<br />

Next i<br />

End Sub<br />

Private Sub cmdQuit_Click()<br />

End<br />

End Sub<br />

Private Sub Form_Load()<br />

‘Initially, regular student should be selected<br />

optReg = True<br />

End Sub<br />

[Run, type in data for Al Adams, press the Add Student button, repeat the process for Brittany Brown <strong>and</strong><br />

Carol Cole, press the Calculate Grades button, <strong>and</strong> then enter data for Daniel Doyle.]<br />

■ KEYS<br />

The items in a collection are automatically paired with the numbers from 1 on. <strong>Visual</strong> <strong>Basic</strong><br />

provides an alternative device for accessing a specific item. At the time an item is added to a<br />

collection, we can associate a key for the item via a statement of the form<br />

collectionName.Add objectName, keyString<br />

After that, the object can be referred to as collectionName.Item(keyString).<br />

A property of the object can be accessed with<br />

collectionName.Item(keyString).property<br />

Collections <strong>and</strong> Events 369

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!