This is a known distance between two points. Can you see if it is helpful?
Hope it will be helpful to you!
'----------------------------------------------------------------------
'The known longitude and latitude Distance Function
'----------------------------------------------------------------------
Function countdistance (byval lon1 as double, byval LAT1 as double, byval lon2 as double, byval LAT2 as double) as double
Dim D as double
Dim A1, A2, B1, B2 as double
A1 = LAT1 * 0.0174532925194
A2 = LAT2 * 0.0174532925194
B1 = lon1 * 0.0174532925194
B2 = lon2 x 0.0174532925194
Countdistance = arccos (math. cos (A1) * Math. cos (A2) * Math. cos (B1) * Math. cos (B2) + math. cos (A1) * Math. sin (B1) * Math. cos (A2) * Math. sin (B2) + math. sin (A1) * Math. sin (A2) * 6371
End Function
Public Function arccos (byval X as double) as double
If CSTR (x) = "1" then
Arccos = 0
Exit Function
Elseif CSTR (x) = "-1" then
Arccos= 3.14159265358979
Exit Function
Else
Arccos = ATN (-x/sqr (-x * x + 1) + 2 * ATN (1)
End if
End Function