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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

380 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

Private Sub cards_shuffling(n As Integer, nMax As Integer)<br />

‘n is the number of the specific pass through the deck (1, 2, 3..)<br />

‘nMax is the total number of passes when the deck is shuffled<br />

picH<strong>and</strong>.Cls<br />

picH<strong>and</strong>.Print “Shuffling Pass:”; n; “out of”; nMax<br />

End Sub<br />

Private Sub cmdQuit_Click()<br />

End<br />

End Sub<br />

[Run, click on the Shuffle button, <strong>and</strong> click on the Deal button after the shuffling is complete.]<br />

COMMENT<br />

1. Example 1 illustrates “use” since the GoDown object of the bomb object<br />

receives a plane object. In general, class A uses Class B if an object of class B<br />

is sent a message by a property or method of class A, or a method or property<br />

of class A returns, receives, or creates objects of class B.<br />

SUMMARY<br />

1. An object is an entity that stores data, has methods that manipulate the data, <strong>and</strong><br />

can trigger events. A class describes a group of similar objects. A method specifies<br />

the way in which an object’s data are manipulated. An event is a change in<br />

the state of an object.<br />

2. Classes are defined in a separate module called a class module. Data is stored<br />

in member variables <strong>and</strong> accessed by procedures called methods.<br />

3. Property Let <strong>and</strong> Property Get procedures are used to set <strong>and</strong> retrieve values of<br />

member variables. These procedures can also be used enforce constraints <strong>and</strong><br />

carry out validation.<br />

4. The Initialize <strong>and</strong> Terminate event procedures are automatically invoked when<br />

an object is created <strong>and</strong> falls out of scope, respectively.<br />

5. An object variable is declared in the declarations section of a program with a<br />

statement of the form Private objectName As className <strong>and</strong> created<br />

with a statement of the form Set objectName = New className.<br />

6. A collection is a convenient devise for grouping together diverse objects.<br />

Objects are added to collections with the Add method <strong>and</strong> removed with the

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

Saved successfully!

Ooh no, something went wrong!