Results 1 to 3 of 3

Thread: Need Help Reformatting DMS String

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    4

    Need Help Reformatting DMS String

    Hello,

    I am trying to reformat my raw string to make it look like the following converted string.

    Raw:
    45 29 55.6929602297123 N 66 8 25.0543388360666 W

    Converted:
    45295569N066082505W

    Formatting issues:
    As you can see in the W, the 66 must be formatted 066(3-digit) and all the others must 2-digit, i.e. with 8 must be 08. Also, the only the first 2-decimal points are used.

    Thank you for your help.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Need Help Reformatting DMS String

    You need to first parse the original String, which would most likely be done by calling String.Split and then converting the numeric elements to the appropriate numeric types using CInt and CDec or, preferably, Convert.ToInteger and Convert.ToDecimal. You can then multiply the two Decimal values by 100 and then it's a simple call to String.Format to create the output.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    4

    Re: Need Help Reformatting DMS String

    Thanks, that was enough to get me thinking in the right direction. I have the converter built thanks to your help.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width