How do I convert from decimal degrees to degrees, minutes and sec.

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top