Public Sub CalcDistance(CurrentLat As Double,CurrentLong As Double,HouseLat As Double,HouseLong As Double) As Double
Try
Dim LatP As Double=CurrentLat
Dim LongP As Double=CurrentLong
Dim LatD As Double=HouseLat
Dim LongD As Double=HouseLong
Dim Miles As Double
Dim Yards As Double
Dim X As Double
Dim Coeff As Double= 1760.0
X = Sin(LatP * 0.01745) * Sin(LatD * 0.01745) + Cos(LatP * 0.01745)* Cos(LatD * 0.01745) * Cos(( LongD - LongP ) * 0.01745)
Miles = 1.15 * 3963 * ( ATan(-X / Sqrt(-X * X+ 1.0000000000001)) + 2* ATan(1) )
Miles = Round2(Miles, 2)
Yards = Miles * Coeff
Return Round( Yards)
Catch
Log("CalcDistance " & LastException)
ShowError("CalcDistance " & LastException)
Return -1
End Try
End Sub