Re: Regional settings cause runtime crash
- From: "Armin Zingler" <az.nospam@xxxxxxxxxx>
- Date: Sat, 14 Jan 2006 12:31:56 +0100
"Colmag" <Colmag@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb
Marina,
Thanks for the suggestion. It seems I'm doing something dodgy in converting variable types.
Because there are so many places where people have restricted access rights, I've avoided writing anything to the registry. To store application settings such as window positions, I write a text file containing these settings when the app closes, and read the config file when the app starts.
I'm declaring a variable as a string which equals a line from the text file and then applying that to my application. e.g:
Dim MainTop As String = streamtoread.ReadLine Me.top = MainTop
The main problem seems to be that you don't use Option Strict. If you used it you would be aware of all conversions taking place.
With appropriate regional settings (decimal separator = .) .net converts the string to an integer no problem, but as soon as I change the regional setting to something like a comma, the conversion no longer works.
Are you sure at this line? I haven't seen an integer using a decimal separator, ever. ;-) How do you /write/ the line into the file?
Whenever you use the text representation of a value you must be aware of the format being used. Internally, one should store all values in it's native format, i.e. date values in DateTime variables etc. If you convert a value from it's native format to string or vice versa, the string format must be taken into account. To store and read application settings, you should use a fixed format. You can use the InvariantCulture to do this. Your application will run independent from the regional settings of the machine where it is running on. To present data to the user, use the regional settings that are usually used automatically used if you use ToString or Parse without additional formatting information.
Armin
.
- References:
- Re: Regional settings cause runtime crash
- From: Marina
- Re: Regional settings cause runtime crash
- From: Colmag
- Re: Regional settings cause runtime crash
- Prev by Date: [VB.NET express 2005] - Regular expressions
- Next by Date: Re: [VB.NET express 2005] - Regular expressions
- Previous by thread: Re: Regional settings cause runtime crash
- Next by thread: Re: Regional settings cause runtime crash
- Index(es):
Relevant Pages
|