|
|
SynopsisThis function converts a Degrees, Minutes and Seconds value to a Decimal Degrees value. For example, 17°30'34" to 17.5094444444444 CODE ' DDMMSStoDD
' http://www.utteraccess.com/wiki/index.php/DDMMSStoDD ' Code courtesy of UtterAccess Wiki ' Licensed under Creative Commons License ' http://creativecommons.org/licenses/by-sa/3.0/ ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' rev date brief descripton ' 1.0 2010-11-09 ' Public Function DDMMSStoDD(sDDMMSS As String) As Double ' This function converts a Degrees, Minutes, Seconds value ' to a Degrees Decimal Value. ' ' The input must contain be in this format: ' #°#'#" ' The Minutes (') and Seconds (") are optional ' Dim iDeg As Integer Dim iMin As Integer Dim iSec As Integer Dim iDegPos As Integer Dim iMinPos As Integer Dim iSecPos As Integer iDegPos = InStr(1, sDDMMSS, Chr(176)) iMinPos = InStr(1, sDDMMSS, "'") iSecPos = InStr(1, sDDMMSS, """") If iDegPos = 0 Then iDeg = 0 Else iDeg = Int(Left(sDDMMSS, iDegPos - 1)) End If If iMinPos = 0 Then iMin = 0 Else iMin = Int(Mid(sDDMMSS, iDegPos + 1, iMinPos - 1 - iDegPos)) End If If iSecPos = 0 Then iSec = 0 Else iSec = Int(Mid(sDDMMSS, iMinPos + 1, iSecPos - 1 - iMinPos)) End If DDMMSStoDD = iDeg + (iMin / 60) + (iSec / 3600) End Function
|
| This page has been accessed 855 times. This page was last modified 08:28, 6 April 2011 by Jack Leach. Disclaimers |