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.

frmCircles.ForeColor = vbRed ‘Make future circles red<br />

End If<br />

End Sub<br />

Private Sub cmdQuit_Click()<br />

End<br />

End Sub<br />

[Run <strong>and</strong> press the “Move <strong>and</strong> Show Circle” button seven times. Note: The last circle will be colored<br />

red.]<br />

COMMENTS<br />

1. Perhaps a better name for “user-defined events.” would be “programmerdefined<br />

events.”<br />

2. A statement of the form<br />

collectionName.Add objectName, keyString<br />

can also be written as<br />

collectionName.Add Item:=objectName, Key:=keyString<br />

3. The WithEvents keyword cannot be inserted into a declaration statement of the<br />

form<br />

Private objectName As Object<br />

It can only be used when a specific class follows the word “As.”<br />

4. Collections require more memory than arrays <strong>and</strong> slow down execution time. If<br />

either a collection or an array would suffice, choose an array. This will often be<br />

the case when the number of items is fixed. For instance, a deck of cards should<br />

be represented as an array of card objects rather than a collection of card<br />

objects.<br />

12.3 CLASS RELATIONSHIPS<br />

Collections <strong>and</strong> Events 373<br />

The three relationships between classes are “use,” “containment,” <strong>and</strong> “inheritance.” One class<br />

uses another class if it manipulates objects of that class. We say that class A contains class B

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

Saved successfully!

Ooh no, something went wrong!