Sub btnSearch_Click
Dim p1_x, p1_y, distanceNew As Float
Dim distanceShortest As Float = Power(10, 38) ' Largest positive flosting point number possible (I think)
Dim intIndex As Int
Dim a As Float = "4516.33696"
Dim b As Float = "1850.84114"
txt2.Text = ""
txt3.Text = ""
txt4.Text = ""
txt5.Text = ""
' I'm taking a guess that these values will be static whilst looping through the list!!!
Dim p2_x As Float = a 'txtLat.Text
Dim p2_y As Float = b 'txtlon.Text
For i = 0 To MyList.Size - 1
Dim Line As String = MyList.Get(i)
Dim SplitLine() As String = Regex.Split(";", Line.Replace(":", ""))
p1_x = SplitLine(0)
p1_y = SplitLine(1)
distanceNew = Power(p1_x - p2_x, 2) + Power(p1_y - p2_y, 2) ' I had to look up how to use to the power of a number :-)
Log("dist = " & distanceNew & " shortest=" & distanceShortest)
If distanceNew < distanceShortest Then
distanceShortest = distanceNew
intIndex = i
Log("New shotest distance found... " & distanceShortest & " at index position " & intIndex)
End If
Next
Log("###### Shortest distance found at index " & intIndex)
End Sub