Local Settings and NumberFormat issues

  • Thread starter Thread starter ru
  • Start date Start date
Cor Ligthert said:
@TK2MSFTNGP15.phx.gbl:

Thats the same as Int32.Parse AFAIk, just a bit wordier. :)
I did not check it in Ildas, however I assume you are right, but because it
is wordier is it in my opinion a little bit more compatible.

:-)

Cor
 
Chad Z. Hower aka Kudzu said:
Thats the same as Int32.Parse AFAIk, just a bit wordier. :)

No, it's not the same. 'Convert.ToInt32' will return 0 if 'Nothing' (a null
reference) is passed to it, 'Int32.Parse' will throw an exception.
 
Herfried K. Wagner said:
No, it's not the same. 'Convert.ToInt32' will return 0 if 'Nothing'
(a null reference) is passed to it, 'Int32.Parse' will throw an
exception.

Otherwise its identical. This oddity doesnt seem to be documented either and seems of limited use.

public static int ToInt32(string value);

Declaring Type: System.Convert
Assembly: mscorlib, Version=1.0.5000.0

public static int ToInt32(string value)
{
if (value == null)
{
return 0;
}
return int.Parse(value);
}




--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Ru,

I find the CInt an extremly strong instrucion.

Can you try this.
Set your decimal point to comma.
Have a look if it is done for everything
Create a new form
Drag a textbox on the form
Click on the form and set in than in the loadevent

dim whatever as integer = Cint("1,00")

For me the most compatible in system is this one
System.Convert.ToInt32("1,00")

However Cint should do it and is less typing.

I am interested in the result.

Cor

Hi Cor,

sorry for the delay, but I've been working through the weekend.
I did as you said, build the form in a new project, set the decimal
point to "," then ran the exe, and got the following error on the
Cint("1,00") code:

Additional information: The currency separator information specified
in the NumberFormatInfo is ambiguous for parsing.

If I use System.Convert.ToInt32("1,00") or Integer.Parse I get the
following error:
Additional information: Input string was not in a correct format.

Do you get the same results?

ru
 
Ru,

I don't have English settings, however I saw something strange when I
changed the decimal point in the showed config.

My question was what it does with a complete new application with only one
textbox.
A setting to of the config to comma and one CInt instruction. If that does
not work than you can call it in my opinon a bug.

I have the idea that it is not directly in Net because from what I saw in
that config. (After setting the decimal all showed values where changed
except one).

For me it is not impossible because of what I saw and what you told that it
is a bug in the OS or maybe even more possible one of the security or SP
updates, because you told that you did not have it before.

However, just a guess

Cor
 
I experienced the same bug. Although it was due to regional settings,
the problem itself was that they were not coherent (dot or comma was
irrelevant).

I had the SAME separator for both thousands and decimals in the Number
formatting pane. Therefore string to int cast was ambiguous. I suspect
the issue arises with money settings.

Pascal.




Cor Ligthert ha scritto:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top