EventClassModule类中的代码:
Public WithEvents Object As AcadCircle
Module1中的代码:
Sub Example_AcadApplication_Events() Dim X As New EventClassModule Dim MyCircle As AcadCircle Dim centerPoint(0 To 2) As Double Dim radius As Double centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0# radius = 5# Set MyCircle = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius) Set X.Object = MyCircle
End Sub
Private Sub Object_Modified(ByVal pObject As AutoCAD.IAcadObject) On Error GoTo ERRORHANDLER MsgBox "对象" & pObject.ObjectName & " 的面积为: " & pObject.Area Exit Sub