AnnGetPoint... example for Visual Basic

Note: Also works with Access 95 and 97.

Note: This topic is for Document/Medical only.

In the AnnDrawn event, this example checks to see if the annotation object is a polygon. If it is a polygon, the example gets the number of points that define the object; then it gets the arrays of X and Y coordinates and displays the points in a message box.

Private Sub Lead1_AnnDrawn(ByVal hObject As Long)
  Dim nType As Integer
  Dim a As Integer
  Dim xPoints As Variant  'array for the X coordinates
  Dim yPoints As Variant  'array for the Y coordinates
  Dim nPoints As Long     'number of points in the object
  Dim msg$

  nType = Lead1.AnnGetType(hObject)
  If nType = ANNOBJECT_POLYGON Then  'Is the object a polygon?
    MsgBox "Object is a Polygon"
    nPoints = Lead1.AnnGetPointCount(hObject) 'get the number of points
    xPoints = Lead1.AnnGetPointX(hObject)     'get the X coordinates
    yPoints = Lead1.AnnGetPointY(hObject)     'get the Y coordinates
    msg$ = "("
    For a = 1 To nPoints
     msg$ = msg$ & "{" & CStr(xPoints(a - 1)) & "," & CStr(yPoints(a - 1)) & "}"
    Next
    msg$ = msg$ & ")"
    MsgBox msg$, vbOKOnly, "The Polygon's " & CStr(nPoints) & " points are:"
  End If
End Sub