title: Convert GPS Degrees Minutes Seconds to Decimal Degrees
body: <p>I have a formula that I am using to calculate decimal degrees from gps coordinates.  </p>
  
  <p>GPS Coordinates:
  3800.5825,N
  08735.5417,W</p>
  
  <p>Formula:</p>
  
  <pre><code>Private Function DMStoDD(ByVal toConvert As Double, ByVal Dir As String) As Double
      Dim DD As Double
      Dim deg As Double
      Dim min As Double
      Dim sec As Double
      deg = CDbl(toConvert.ToString.Substring(0, 2))
      min = CDbl(toConvert.ToString.Substring(2, 2))
      sec = CDbl(toConvert.ToString.Split(".")(1)) * 0.01
      DD = deg + (min / 60) + (sec / 3600)
      'Negative for West
      If Dir = "W" Then DD = DD * -1
      Return DD
  End Function
  </code></pre>
  
  <p>Returns:
  38.0161805555556
  -87.5983805555556 (negative for west)
  The results are very close, but not quite right.  I believe that they are just a little bit North West of where they actually should fall.  I have searched and looked at a lot of different formulas, but from what I've read, I think that mine should be right.  Thanks in advance for the help.  </p>