A
Anushi
Hi JH,
The following equation is used to convert latitude and longitude into
decimal degrees.
Decimal degrees = degree + (minute/60) + (sec/3600)
Here's the code snippet to convert from degrees to DMS; and vice-versa..
Code:
Function DMSStrToDeg(ByVal DMS As String) As Double
'
' Converts a string value in the format [d m' s"] to a decimal number.
' Not all elements need be present, and they may contain decimal digits.
' e.g. 15 30' 0" -> 15.5
'
Dim i As Integer, w As String, Temp As Double
Temp = 0
For i = 1 To 3
w = CutWord(DMS, DMS)
Select Case Right(w, 1)
Case "'"
Temp = Temp + Val(w) / 60
Case """"
Temp = Temp + Val(w) / 3600
Case Else
Temp = Temp + Val(w)
End Select
Next i
DMSStrToDeg = Temp
End Function
Code:
Function DMSToDeg(D As Double, M As Double, S As Double) As Double
'
' Converts separate Degree, Minute, Second values into decimal degrees.
' e.g. 15,30,0 -> 15.5
'
DMSToDeg = D + M / 60 + S / 3600
End Function
HTH,
Anushi (Grapecity)
The following equation is used to convert latitude and longitude into
decimal degrees.
Decimal degrees = degree + (minute/60) + (sec/3600)
Here's the code snippet to convert from degrees to DMS; and vice-versa..
Code:
Function DMSStrToDeg(ByVal DMS As String) As Double
'
' Converts a string value in the format [d m' s"] to a decimal number.
' Not all elements need be present, and they may contain decimal digits.
' e.g. 15 30' 0" -> 15.5
'
Dim i As Integer, w As String, Temp As Double
Temp = 0
For i = 1 To 3
w = CutWord(DMS, DMS)
Select Case Right(w, 1)
Case "'"
Temp = Temp + Val(w) / 60
Case """"
Temp = Temp + Val(w) / 3600
Case Else
Temp = Temp + Val(w)
End Select
Next i
DMSStrToDeg = Temp
End Function
Code:
Function DMSToDeg(D As Double, M As Double, S As Double) As Double
'
' Converts separate Degree, Minute, Second values into decimal degrees.
' e.g. 15,30,0 -> 15.5
'
DMSToDeg = D + M / 60 + S / 3600
End Function
HTH,
Anushi (Grapecity)