Grados

Solo disponible en BuenasTareas
  • Páginas : 2 (272 palabras )
  • Descarga(s) : 0
  • Publicado : 13 de noviembre de 2011
Leer documento completo
Vista previa del texto
Convertir los grados decimales a grados, minutos y segundos
La siguiente función personalizada de Microsoft Visual Basic para Aplicaciones acepta un ángulo con formato decimal y loconvierte en un valor de texto que se muestra en grados, minutos y segundos.

Function Convert_Degree(Decimal_Deg) As Variant
With Application'Set degree to Integer of Argument Passed
Degrees = Int(Decimal_Deg)
'Set minutes to 60 times the number to the right'of the decimal for the variable Decimal_Deg
Minutes = (Decimal_Deg - Degrees) * 60
'Set seconds to 60 times the number to the right ofthe
'decimal for the variable Minute
Seconds = Format(((Minutes - Int(Minutes)) * 60), "0")
'Returns the Result of degreeconversion
'(for example, 10.46 = 10~ 27 ' 36")
Convert_Degree = " " & Degrees & "° " & Int(Minutes) & "' " _
& Seconds +Chr(34)
End With
End Function

Convertir los grados, minutos y segundos a grados decimales
Function Convert_Decimal(Degree_Deg As String) As Double
'Declare the variables to be double precision floating-point.

Dim degrees As Double
Dim minutes As Double
Dim seconds As Double
' Set degree to value before "°" of Argument Passed.degrees = Val(Left(Degree_Deg, InStr(1, Degree_Deg, "°") - 1))
' Set minutes to the value between the "°" and the "'"
' of the text string for the variable Degree_Deg divided by
' 60. The Valfunction converts the text string to a number.
minutes = Val(Mid(Degree_Deg, InStr(1, Degree_Deg, "°") + 2, _
InStr(1, Degree_Deg, "'") - InStr(1, Degree_Deg, _
"°")...
tracking img