Consulting

Results 1 to 10 of 10

Thread: Setting text format for a textbook on a form

  1. #1
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location

    Setting text format for a textbook on a form

    How does one set the format for a textbox on a form to accept either time degrees or decimal degrees?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    A TextBox holds text, String Values.

    TextBox1.Value = CStr(DecimalDegreeNumber)
    TextBox2.Value = Degrees & "*:" & Minutes & "':" & Seconds & """
    TextBox1 reads as : 150.82375927
    TextBox2 reads as: 150*:13':34.395"
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Hmmm, what about if I wanted to put a cat amongst the pidgeons by only wanting Degrees &"." & Minutes &"." & Seconds in the form of
    23.45.789 or 150.56.345
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    did you try
    format(2345789,"@@@.@@.@@@")

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    @snb, I did try to write it as txtLatitude1.Value = Format(txtLatitude1.Value, "00.00.000") but haven't tested it yet.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Quote Originally Posted by Aussiebear View Post
    Hmmm, what about if I wanted to put a cat amongst the pidgeons by only wanting Degrees &"." & Minutes &"." & Seconds in the form of
    23.45.789 or 150.56.345
    Use Left(CStr(Seconds * 10), 3)

    If the starting value is Decimal degrees, you will have to convert it to Degrees, Minutes Seconds.

    By definition, in D:M:S Nomenclature, Degrees are integers from 0 to 359 or from -179 to +179, Minutes are integers from 0 to 59, and seconds are doubles from 0 to 59.999...

    For decimal Degrees, Degrees are doubles from -179.999... to +179.999...

    Thought Experiment:
    Function ConvertToDMS(DecDegree As Double) As Variant
    Dim NegativeSign As Boolean
    
    'DecDegree is Double
    Dim dmsDegree As Int
    Dim DecMinute As Double
    Dim dmsMinute As Int
    Dim dmsSecond As Double
    
    
    NegativeSign = DecDegree < 0
    If NegativeSign then DecDegree = DecDegree * -1
    dmsDegree = Int(DecDegree)
    
    DecMinute = DecDegree - dmsDegree
    dmsMinute = Int(DecMinute * 60)
    
    dmsSecond = (DecMinute - dmsMinute) * 60
    
    If NegativeSign Then dmsDegree = dmsDegree * -1
    ConvertToDMS = Array(dmsDegree, dmsMinute, dmsSecond)
    
    End Function
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    I changed the format in #4 to format(y,"@@@.@@.@@@")

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    @SamT

     For decimal Degrees, Degrees are doubles from -179.999... to +179.999...
    Not for latitudes of course
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •