I have the following value 48.81, it comes as a string from the database, I need to convert it to decimal, I’m using:
Dim Seconds As Decimal = Convert.ToDecimal((Coordinate.Substring(4, 5)), CultureInfo.InvariantCulture)
I’m receiving 4881D and I need 48,81
Any ideas? I thought CultureInfo.InvariantCulture was going to help me with that
EDIT
The coordinate value is 675900.244.
I’m “spliting” it like this:
Dim Degress As Integer = Coordinate.Substring(0, 2),
Dim Minutes As Integer = Coordinate.Substring(2, 2),
Dim Seconds As Decimal = Convert.ToDecimal((Coordinate.Substring(4, 5)), CultureInfo.InvariantCulture),
Dim Position As Enumerations.EnumCoordinatesPosition = Coordinate.Substring(9, 1)
EDIT

EDIT

EDIT
This is the value of the coordinate in the database

The problem lies in the variable
databaseCoordinate, which contains comma instead of dot. InvariantCulture uses comma to separate groups of digits and dot as a decimal symbol. To see this execute the following code:What you can do about it:
Specify decimal separator for
Convert.ToDecimalmethod like this:Write update script DB for all DB entries with coordinates to use dot as a decimal symbol.
Example – this code gives the results you are expecting: