• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

vb.net parse issue

Messages
42
Country
unitedkingdom
Hi Guys

Im writing a application in VB.NET that gets the users coordinates from FS in DMS and then converts them to Decimal Degrees. The conversion is working fine the issue im having is when I parse out the coordinates string to convert.

here is my current code to parse out the coordinates:
Code:
'parse out the Lat N or S
            Dim lat_NS As String
            lat_NS = Mid(Lat_str, 1, 1)
            'parse out the Lat Degrees
            Dim lat_Deg As Double
            lat_Deg = Mid(Lat_str, 2, 3)
            'parse out the Lat Minutes
            Dim lat_Min As Double
            lat_Min = Mid(Lat_str, 7, 2)
            'parse out the Lat Seconds
            Dim lat_Sec As Double
            lat_Sec = Mid(Lat_str, 10, 2)

            'Get Lon in var
            Dim Lon_str As String
            Lon_str = txtLongitude.Text

            'parse out the Lat E or W
            Dim lon_EW As String
            lon_EW = Mid(Lon_str, 1, 1)
            'parse out the Lat Degrees
            Dim lon_Deg As Double
            lon_Deg = Mid(Lon_str, 2, 3)
            'parse out the Lat Minutes
            Dim lon_Min As Double
            lon_Min = Mid(Lon_str, 7, 2)
            'parse out the Lat Seconds
            Dim lon_Sec As Double
            lon_Sec = Mid(Lon_str, 10, 2)

but say for example my lat lon was N053° 02.64' W000° 22,03'

it would loose all the 0's so it would return N53° 2.64' W0° 22,3' and that could take to to a different place how can I tell it to keep the 0's in

Many Thanks
Scott
 
Not sure I understand your issue, but can you use the split function and work on each part by checking their length.

Dim LongArray() As String = txtLongitude.Text.Split(New Char() {" "c})
' LongArray(0) is Long degrees
' LongArray(1) is decimal minutes

' if LongArray(0).Length = 3 you have W0°
' if LongArray(0).Length = 4 you have W10° to W99
' if LongArray(0).Length = 5 you have W100° to 180

https://msdn.microsoft.com/en-us/library/ms131448(v=vs.100).aspx
 
Last edited:
Thanks I have changed my code to get decimal degrees directly from FSX so it has solved the issue without having to parse all the coordinates now
 
Just to check Scott, are you suggesting that W0˚ and W000˚ are different? I see the problem with 22.3 vs 22.03 but fundamentally all the other elements seem identical to me.
I do have a bit of code to convert various formats of coordinates to radians if that might be of any help.

Z
 
Back
Top