Welcome to Dream.In.Code
Become a VB Expert!

Join 149,463 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,067 people online right now. Registration is fast and FREE... Join Now!




Eliminating the zero BEFORE the decimal point

 
Reply to this topicStart new topic

Eliminating the zero BEFORE the decimal point, Degrees minutes seconds to decimal degrees

tiff_33
24 Jan, 2008 - 04:00 PM
Post #1

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 1

Hi. I am a complete beginner. This is the first time I've done code. I know the code is sloppy but I know I can get it to work and will clean it up after finding out this answer.
I am writing a code to convert degrees minutes and seconds to decimal degrees.
My big obstacle right now is that when I compute the minutes it adds a zero to the left of the equation. So, instead of reading "1.234" like it should, it looks like "10.234"
Thanks so much!
Tiffany

CODE

    Dim dmsDegrees As Single 'Sets the degrees, minutes and seconds to single variable
    Dim dmsminutes As Single
    Dim dmsseconds As Single
    Dim Acoord As String 'Set to string b/c it is text
    Acoord = "-80 33 15"
    dmsDegrees = -80 'Gives values to the degrees, minutes and seconds
    dmsminutes = 33
    dmsseconds = 15
    
    'Sets up an input box for putting in degrees, minutes and seconds
    dmsA = InputBox( _
        "Enter Degrees", _
        "Degrees, Minutes, & Seconds")
      
    Adegrees = (dmsA) 'gives value to the Adegree variable
    
    'Presents the answer to the value inputted in a message box
    MsgBox "The Decimal Degrees is: " & Adegrees, _
        vbInformation

    dmsB = InputBox( _
        "Enter Minutes", _
        "Degrees, Minutes, & Seconds")
        
    aminutes = (dmsB / 60) 'Computes the minutes data to decimal degree format
        
    MsgBox "The Decimal Degrees is: " & aminutes, _
        vbInformation

    dmsC = InputBox( _
        "Enter Seconds", _
        "Degrees, Minutes, & Seconds")
        
    aseconds = (dmsC / 3600) 'Computes the seconds data to decimal degree format
    
    afterdecimal = aminutes + aseconds 'Adds the mintues and seconds
        
    MsgBox "The Decimal Degrees is: " & aseconds, _
        vbInformation
        
    msg = dmsA & afterdecimal 'Presents the answer
    ans = MsgBox(Acoord & " converts to " & msg)



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 02:09PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month