Sub Area_Click
lastpoint = tgtnum.Text + 0
' check with the user that the last point is defined.
If Msgbox("Last point is " & lastpoint & " ?", "Last Point" ,cMsgboxYesNo, cMsgboxNone)= cNo Then Return
' find the minimum of UTM_Y of all the points
miny = point(1).utm_y
For i = 2 To lastpoint
If point(i).utm_y < miny Then miny = point(i).utm_y
Next
' sum all rectangles of two following points
total_area = 0
For i = 1 To lastpoint - 1
total_area = total_area + ((point(i).utm_y + point(i+1).utm_y)/2 - miny) * (point(i+1).utm_x - point(i).utm_x)
Next
' also between the last and the first - now it is a closed loop.
total_area = total_area + ((point(lastpoint).utm_y + point(1).utm_y)/2 - miny) * (point(1).utm_x - point(lastpoint).utm_x)
total_area = Abs(total_area/1000000) ' change from sqr meters to sqr KM
sqrkm.Text = Format(total_area,"N3")
dunham.Text = Format(total_area * 1000, "N1") ' or in Dunhams
acre.Text = Format(247.105 381 47 * total_area,"N3") ' or in Acres
areapanel.Visible = True
End Sub