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.

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

End Sub<br />

‘Form code<br />

Private round As CCircle<br />

Private Sub Form_Load()<br />

Set round = New CCircle<br />

End Sub<br />

Private Sub cmdMove_Click()<br />

round.Move (500)<br />

End Sub<br />

Private Sub cmdQuit_Click()<br />

End<br />

End Sub<br />

[Run, <strong>and</strong> press the comm<strong>and</strong> button five times.]<br />

COMMENTS<br />

1. The statement<br />

Set objectVar = Nothing<br />

dissociates the object variable from the actual object <strong>and</strong> frees up the memory<br />

used by the variable.<br />

2. An object variable declared inside a procedure ceases to exist when the procedure<br />

is exited. (We say that the object falls out of scope.) The effect is the same<br />

as when the variable is set to Nothing.<br />

3. The counterpart to the Initialize event is the Terminate event procedure which<br />

has the template<br />

Private Sub Class_Terminate()<br />

End Sub<br />

<strong>and</strong> is automatically invoked when all references to the object are Set to Nothing<br />

or when the object falls out of scope. This procedure is often used to set any<br />

objects you may have created inside the class module to Nothing.

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

Saved successfully!

Ooh no, something went wrong!