Public Class listing14_2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Private Sub InitializeComponent() components = New System.ComponentModel.Container() Me.Text = "listing14_2" End Sub #End Region Public Interface Shape Function IsPtInShape(ByVal Pt As System.Drawing.Point) As Boolean End Interface Public Class Rectangle Implements Shape Private rect As Drawing.Rectangle Public Function PtInRect(ByVal Pt As System.Drawing.Point) As Boolean _ Implements Shape.IsPtInShape PtInRect = Pt.Equals(rect) End Function End Class Public Class Circle Implements Shape Private rgn As Drawing.Region Public Function PtInCircle(ByVal Pt As System.Drawing.Point) As Boolean _ Implements Shape.IsPtInShape PtInCircle = Pt.Equals(rgn) End Function End Class Sub CheckPoint(ByVal ShapeObject As Shape, ByVal Pt As System.Drawing.Point) If (ShapeObject.IsPtInShape(Pt)) Then Beep() End If End Sub Sub Test() Dim Pt As System.Drawing.Point Dim RectObject As Rectangle Dim CircleObject As Circle CheckPoint(RectObject, Pt) CheckPoint(CircleObject, Pt) End Sub End Class