decimal - vb.net Convert.ToDecimal Not working -


i writing program reads gps coordinates. gps coordinates in string format so:

42,9659 15,3167

i want convert these strings decimals. on development pc works fine, put software on pc doesn't convert decimal. outputs value without comma, so:

429659 153167

heres code:

gpslatdecimalstring = gpsdata(2).substring(2, gpsdata(2).length - 2).replace(".", ",") gpslongdecimalstring = gpsdata(4).substring(3, gpsdata(4).length - 3).replace(".", ",")  'lat: 25.69953 'long: 28.23881  gpslatdecimal = system.convert.todecimal(gpslatdecimalstring) gpslongdecimal = system.convert.todecimal(gpslongdecimalstring) 

it seems coordinates in form xxxxx(point)yyyyy , problem in pc os configured different cultures.

do not try replace point comma, use instead appropriate iformatprovider in call convert.todecimal

gpslatdecimalstring = gpsdata(2).substring(2, gpsdata(2).length - 2) gpslongdecimalstring = gpsdata(4).substring(3, gpsdata(4).length - 3)  gpslatdecimal = convert.todecimal(gpslatdecimalstring, cultureinfo.invariantculture) gpslongdecimal = convert.todecimal(gpslongdecimalstring, cultureinfo.invariantculture) 

now, on pc (probably configured comma decimal separator), converter informed use invariantculture understand string while, on other pc point configured decimal separator, default , cultureinfo parameter has no effect.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -