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.

SOLUTION:<br />

Object Property Setting<br />

frmCircles BorderStyle 0-None<br />

cmdMove Caption Move <strong>and</strong> Show Circle<br />

cmdQuit Caption Quit<br />

‘Class module for CCircle<br />

Private m_x As Integer ‘Dist from center of circle to left side of form<br />

Private m_y As Integer ‘Distance from center of circle to top of form<br />

Private m_r As Single ‘Radius of circle<br />

Private Sub Class_Initialize()<br />

‘Set the initial center of the circle to the upper<br />

‘left corner of the form <strong>and</strong> set its radius to 500.<br />

m_x = 0<br />

m_y = 0<br />

m_r = 500<br />

End Sub<br />

Public Property Get Xcoord()<br />

As Integer Xcoord = m_x<br />

End Property<br />

Public Property Let Xcoord(ByVal vNewValue As Integer)<br />

m_x = vNewValue<br />

End Property<br />

Public Property Get Ycoord() As Integer<br />

Ycoord = m_y<br />

End Property<br />

Public Property Let Ycoord(ByVal vNewValue As Integer)<br />

m_y = vNewValue<br />

End Property<br />

Public Sub Show()<br />

‘Display the circle.<br />

‘See discussion of Circle method in Section 10.4.<br />

frmCircles.Circle (m_x, m_y), m_r<br />

End Sub<br />

Public Sub Move(Dist)<br />

‘Move the center of the circle Dist twips to the right<br />

‘<strong>and</strong> Dist twips down.<br />

m_x = m_x + Dist<br />

m_y = m_y + Dist<br />

Call Show<br />

Classes <strong>and</strong> Objects 363

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

Saved successfully!

Ooh no, something went wrong!