Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

How to increase decimal places in this function (Excel)

$
0
0
Hi all, I found this function to convert Decimal Degrees to Degrees/Minutes/Seconds at this website (https://docs.microsoft.com/en-US/off...seconds-angles)
Code:

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 of the
        'decimal for the variable Minute
        Seconds = Format(((Minutes - Int(Minutes)) * 60), "0")
        'Returns the Result of degree conversion
        '(for example, 10.46 = 10~ 27  ' 36")
        Convert_Degree = " " & Degrees & "° " & Int(Minutes) & " ' " & Seconds + Chr(34)
    End With
End Function

The only problem is I need the seconds number to two decimal places.

E.g 38.93821121 converts to 38° 56 ' 17". However I want it to show as 38° 56 ' 17.56"

If anyone knows how to modify the function it will be greatly appreciated. Thanks!

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>