Sub btnOK_click
'find # of points used for area calc
Dim x,areasqft,pts(),j,firstpt,points,ptnum
Dim numpts,num(),total1,total2
x=0
points="9,7,3,4,2,8,0,"
num=Regex.Split(",",points)
For i=0 To 20
ptnum=num(i)
x=x+1
If ptnum="0" Then
Exit
End If
Next
numpts=x-1
'here is where the comparison should begin
'get coord of first point in line of numbers
j=0 'first point in line of numbers
Dim cline()
Dim reader As TextReader
reader.Initialize (File.openinput(File.DirInternal,main.strfilename ))
Dim lineoftext As String
lineoftext=reader.ReadLine ' get the first line
Do While lineoftext<>Null
cline=Regex.Split(",",lineoftext)'added this here
If cline(0)=num(j) Then
main.dblnorth=cline(1)
main.dbleast=cline(2)
Exit
End If
lineoftext=reader.ReadLine ' get next line - this is tested for Null on next loop
Loop
reader.Close
'get remainder of coordinates for points
For i=1 To x-1
reader.Close
reader.Initialize (File.openinput(File.DirInternal,main.strfilename ))
lineoftext=reader.ReadLine
Do Until lineoftext=Null 'also tried do while lineoftext<>null
cline=Regex.Split(",",lineoftext)
If cline(0)=num(i) Then
main.dblnortha=cline(1)
main.dbleasta=cline(2)
Areasqft = Areasqft + (main.dblNorth * main.dbleasta) - (main.dblnortha * main.dblEast) [color=red] error is 'numberformat exception [/color]
main.dblnorth=main.dblnortha
main.dbleast=main.dbleasta
End If
lineoftext=reader.ReadLine
Loop
Next
reader.close
areasqft=areasqft/2 'sets area for all tangents
txtresults.text=txtresults.text & areasqft
End Sub