I created the following.
- Code: Select all
function f_Deg( dblRad as double ) as double
' converts rad to degree
dim Pi as double
PI = atn(1) * 4
return dblRad * 180.0/PI
end function
function f_strDMS( dblDeg as double ) as string
' creates a string from angle in Deg
' as angle in Degree, Minutes and Seconds
' W. Oestreicher
dim intG as integer , intM as integer , intSC as integer
dim dblS as double , dblB as double
dim strSign as string *2
dim strOut as string
strSign = iif (dblDeg < 0 , "-", "")
dblB = round(abs(dblDeg) * 360000)
intG = dblB \ 360000
intM = (dblB - intG * 360000) \ 6000
intSC = (dblB - intG * 360000 - intM * 6000)
dblS = intSC / 100
if intSC > 0 then
strOut = strSign & intG & "°" & intM & "'" & dblS & Chr(34)
elseif intM > 0 then
strOut = strSign & intG & "°" & intM & "'"
else
strOut = strSign & intG & "°"
end if
return strOut
end function
sub Main()
Dim dblA as double
dblA = f_deg( CMath.asin(3/4) )
? dblA & "° = " & f_strDMS ( dblA )
end sub
Main()