Public Class frmCircle

  Dim round As New Circle()

  Private Sub btnMove_Click(ByVal sender As System.Object,
                            ByVal e As System.EventArgs) Handles btnMove.Click
    round.Move(20)
    round.Show(picCircle.CreateGraphics)
  End Sub

  Private Sub btnQuit_Click(ByVal sender As System.Object,
                            ByVal e As System.EventArgs) Handles btnQuit.Click
    Me.Close()
  End Sub
End Class     'frmCircle

Class Circle
  Private m_x As Integer  'Dist from left side of picture box to circle
  Private m_y As Integer  'Distance from top of picture box to circle
  Private m_d As Integer  'Diameter of circle

  Public Sub New()
    'Set the initial location of the circle to the upper-left
    'corner of the picture box, and set its diameter to 40.
    Xcoord = 0
    Ycoord = 0
    Diameter = 40
  End Sub

  Public Property Xcoord() As Integer
    Get
      Return m_x
    End Get
    Set(ByVal value As Integer)
      m_x = value
    End Set
  End Property

  Public Property Ycoord() As Integer
    Get
      Return m_y
    End Get
    Set(ByVal value As Integer)
      m_y = value
    End Set
  End Property

  Public Property Diameter() As Integer
    Get
      Return m_d
    End Get
    Set(ByVal value As Integer)
      m_d = value
    End Set
  End Property

  Sub Show(ByVal g As Graphics)
    'Draw a circle with the given graphics context
    g.DrawEllipse(Pens.Black, Xcoord, Ycoord, Diameter, Diameter)
  End Sub

  Sub Move(ByVal distance As Integer)
    Xcoord += distance
    Ycoord += distance
  End Sub
End Class     'Circle
