Ghobashi Level: Sage

 Registered: 28-02-2003 Posts: 61
|
Please help me
Hello
I have a text file with alot of observations in Degree minutes seconds
I want to develope the attached code so as to read from the file and then convert it to decimal format
can you help me?
If the text file's name is "coordinates"
Private Function invert() As Double
' Declare the variables to be double precision floating-point.
Dim degrees As Double
Dim minutes As Double
Dim seconds As Double
Dim sixarc As String
sixarc = "10° 27' 36"""
' Set degree to value before "°" of Argument Passed
degrees = Val(Left(sixarc, InStr(1, sixarc, "°") - 1))
' Set minutes to the value between the "°" and the "'"
' of the text string for the variable Degree_Deg divided
' 60. The Val function converts the text string to a number.
minutes = Val(Mid(sixarc, InStr(1, sixarc, "°") + 2, _
InStr(1, sixarc, "'") - InStr(1, sixarc, _
"°") - 2)) / 60
' Set seconds to the number to the right of "'" that is
' converted to a value and then divided by 3600.
seconds = Val(Mid(sixarc, InStr(1, sixarc, "'") + _
2, Len(sixarc) - InStr(1, sixarc, "'") - 2)) _
/ 3600
MsgBox degrees + minutes + seconds
End Function
|
____________________________
with Respect
|