0

How to check if the value in the array is higher. My case I have Designpoints count =12 and FromNode value =11. The problem is that DesignPoints(12) does not exist since Designpoints start count from 0.I get an error in "If Designpoints(FromNode + 1).tag = "WALL" Then" Gets and error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

For gcount = 0 To GroundPoints.Count - 2
   For Dcount = 0 To Designpoints.Count - 2
      If Designpoints(FromNode + 1).tag = "WALL" Then
        polygon.PolyGonType = XpolyType.StructureCut
        customPolygon.Add(polygon)
      Else

Is there any way to check if the FromNode value is always less than the Designpoints value. I tried to check the condition like

If Designpoints.count > FromNode + 1 And Designpoints(FromNode + 1).tag = "WALL" Then

Also tried putting "Designpoints(FromNode + 1).tag = "WALL" " inside the "If Designpoints.count > FromNode + 1" loop

ritesh khadka
  • 152
  • 2
  • 13
  • 1
    Use `AndAlso` instead of `And`. The latter always evaluates both sides, thus even if your left statement determines that it is out of range, it will still check the right one as well. – Visual Vincent Aug 03 '18 at 09:19
  • I read somewhere AndAlso is used for numeric comparison only. So I did not tried it, Thank you any way. – ritesh khadka Aug 03 '18 at 10:20

0 Answers0