kellydn

Assigning X,Y coordinates to a point using VB.net

Discussion created by kellydn on Sep 2, 2012
Latest reply on Sep 3, 2012 by kellydn
I am converting vba code to run in VB.net in ArcGIS 10.  The code is supposed to read a text file of coordinates, creates points with the  X,Y coordinates.  When the code tries to set the value of x to pPoint(i).X, the code crashes. x and y both have the correct double values(coordinates).

Any body have an idea what I am doing wrong?



        Dim pointColl As IPointCollection4 = New Polygon

        Dim pPoint() As IPoint

        Dim i As Long = 10000

        ReDim pPoint(0 To CInt(i - 1))

        i = 0

        noCats = 1

        'Read coords into points

          Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(VSTabTextFile)
          MyReader.TextFieldType = FileIO.FieldType.Delimited
          MyReader.SetDelimiters(",")

          Dim currentRow As String()

          currentRow = MyReader.ReadFields()
          currentRow = MyReader.ReadFields()
          testPM = Convert.ToDouble(currentRow(0))
          PM = Convert.ToDouble(currentRow(0))

          While Not MyReader.EndOfData
                If testPM = PM Then
                    PM = Convert.ToDouble(currentRow(0))
                    x = Convert.ToDouble(currentRow(1))
                    y = Convert.ToDouble(currentRow(2))

                    pPoint(i).X = x
                    pPoint(i).Y = y

                    pointColl.AddPoint(pPoint)

                    i = i + 1

                    currentRow = MyReader.ReadFields()a polygon.
          end while

Outcomes