title: getting array error in autocad vba. subscript out of range
body: <p>i am trying to create code which select polygons and tell what it contains i.e mtext.
  but i am getting error while redim array.</p>
  
  <p>below is the code for it. its giving subscript</p>
  
  <pre><code>Sub polycoords()
     Dim objSSet As AcadSelectionSet, a As AcadLWPolyline, objSSet1 As AcadSelectionSet, a1 As AcadMText, pointsArray() As Double, j As Integer, i As Integer
      Dim lngMode As Long, cc As Integer
      If Not objSSet Is Nothing Then
          objSSet.Delete
       End If
      Set objSSet = ThisDrawing.SelectionSets.Add("443t39cr2t")
  
      objSSet.SelectOnScreen
  
       For Each a In objSSet
  
  
  
           ReDim pointsArray(0 To UBound(a.Coordinates) + UBound(a.Coordinates) / 2)
           j = 0
           For i = 0 To UBound(a.Coordinates) + UBound(a.Coordinates) / 2 Step 2
               pointsArray(j) = a.Coordinates(i)
               j = j + 1
               pointsArray(j) = a.Coordinates(i)
               j = j + 1
               pointsArray(j) = a.Coordinates(i)
               j = j + 1
           Next i
  
                 Set objSSet1 = ThisDrawing.SelectionSets.Add("g44c3rt2it")
                 lngMode = acSelectionSetWindowPolygon
  
                 objSSet1.SelectByPolygon lngMode, pointsArray
                For Each a1 In objSSet1
                    Debug.Print a1.TextString
                Next a1
  
           Debug.Print vbNewLine
  
           On Error Resume Next
       Next a
       If Not objSSet Is Nothing Then
          objSSet.Delete
       End If
  
  
  End Sub
  </code></pre>