Dim a As Double
Dim c As Double
Dim d As Double
Dim Dlt As Double
Dim DLon As Double
Private Const pi As Double = 3.14159265358979
Public Function atan2(y As Double, x As Double) As Double
If x > 0 Then
atan2 = Atn(y / x)
ElseIf x < 0 Then
atan2 = Sgn(y) * (pi - Atn(Abs(y / x)))
ElseIf y = 0 Then
atan2 = 0
Else
atan2 = Sgn(y) * pi / 2
End If
End Function
Private Sub Command1_Click()
lat1 = (Text1.Text * pi) / 180
lat2 = (Text3.Text * pi) / 180
Long1 = (Text2.Text * pi) / 180
Long2 = (Text4.Text * pi) / 180
dlat = Abs(L1t1 - lat2)
DLon = Abs(Long1 - Long2)
r = 6371
a = (Math.Sin(dlat / 2)) ^ 2 + Math.Cos(lat1) * Math.Cos(lat2) * (Sin(DLon / 2)) ^ 2
c = 2 * atan2(Sqr(a), Sqr(1 - a))
d = r * c
Text5.Text = d
End Sub
My program coding are as above,for Haversine formula to calculate great circle distances,p1 and p2 coordinates as below in decimal dergrees
p1
lat1-7.000664 N
lat2-80.411697 E
p2
long1-6.548509 N
long2-80.412038 E
Expected answer is 50 km,but the program giving 728.160
I can't recognize what is my fault.im using VB 6,
Can anyone help me please...

