![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
|
Hi there, We have coded a pretty big application that's dealing with plain text files containing float numbers with the format "33.21" for instance. So what we are doing when importing those files into our app is myFloatNumber = Csng(myNumberStr) Everything worked find until we tried our app on a French and a Russian operating system. Since the Decimal Separator for France and Russia is ",", the CSng cast crashes becose "33.21" means nothing ("33,21" wowuld have been correct). A radical solution would be to set the regional settings of the computer to Decimal Separator = "," but we can't ask our russian customers to do so just for our software. Another solution would have been to change all the lines where we are doing a cast from String to Single and Double (you may have heard about CultureIndependant stuffs), but it's a huge pain in the arse to change our code (and it seems that doing some CultureIndependant cast may result in weird stuff.). My idea were finally to set the DecimalSeparator to ".", but just for our application, not for the entire system. I was pretty happy to see that the property system.Globalization.CultureInfo.CurrentCulture.Nu mberFormat.NumberDecimalSeparator = "." would be enough, but unfortunately I got an exception telling me that the propery is readonly : An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll Additional information: Instance is read-only. Then I'm looking for a way to set the DecimalSeparator at the beginning of my app, that's all ! Thx in advance Sylvain |
#2
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |