Local Settings and NumberFormat issues

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ru

    #1

    Local Settings and NumberFormat issues


    I got an error message from a client running my software, and after
    building a test machine with the exact regional settings as my client
    I could reproduce the bug. The setting causing the bug turned out to
    be the decimal symbol set to ",".

    The error message was: "The currency separator information specified
    in the NumberFormatInf o is ambiguous for parsing."

    The code causing the error was a simple one:
    int100 = CInt(txt100.Tex t)

    int100 is an integer
    txt100 is a textbox displaying an integer variable: there's no decimal
    separator involved, so I don't know why this is raising an error.

    Changing the code to:
    int100 = Integer.Parse(t xt100History.Te xt,
    NumberStyles.Al lowDecimalPoint )
    cleared the error.

    Another thing I discovered was that the IsNumeric function also didn't
    work properly. The following code would always return false, no matter
    what key was pressed:

    Private Sub txtScore_TextCh anged(ByVal sender As Object, ByVal e As
    System.EventArg s) Handles txtScore.TextCh anged
    If IsNumeric(txtSc ore.Text) = False Then
    txtScore.Text = ""
    End If
    'End Sub

    Can someone explain why the errors were thrown, eventhough no decimal
    separators were involved? And also, what's the best way in dealing
    with different regional settings?

    Thanks,
    ru






  • Cor Ligthert

    #2
    Re: Local Settings and NumberFormat issues

    Ru,

    From your message I get the idea that you have set some regional settings.

    Can that be true?

    And than which?

    Cor


    Comment

    • ru

      #3
      Re: Local Settings and NumberFormat issues

      On Fri, 17 Jun 2005 16:11:53 +0200, "Cor Ligthert"
      <notmyfirstname @planet.nl> wrote:
      [color=blue]
      >Ru,
      >
      >From your message I get the idea that you have set some regional settings.
      >
      >Can that be true?
      >
      >And than which?
      >
      >Cor
      >[/color]

      Hi Cor,

      like I said in the original message:
      The setting causing the bug turned out to
      be the decimal symbol set to "," in the regional settings.

      ru

      Comment

      • Cor Ligthert

        #4
        Re: Local Settings and NumberFormat issues

        Ru,
        [color=blue]
        > be the decimal symbol set to "," in the regional settings.
        >[/color]
        Is this meant as joke?

        Cor


        Comment

        • ru

          #5
          Re: Local Settings and NumberFormat issues

          On Fri, 17 Jun 2005 17:38:08 +0200, "Cor Ligthert"
          <notmyfirstname @planet.nl> wrote:
          [color=blue]
          >Ru,
          >[color=green]
          >> be the decimal symbol set to "," in the regional settings.
          >>[/color]
          >Is this meant as joke?
          >
          >Cor
          >[/color]

          No, why?

          My client's decimal symbol was set to ",".

          ru

          Comment

          • Cor Ligthert

            #6
            Re: Local Settings and NumberFormat issues

            Ru,

            Probably in most systems in the world is the decimal point a ","

            Cor


            Comment

            • Chad Z. Hower aka Kudzu

              #7
              Re: Local Settings and NumberFormat issues

              "Cor Ligthert" <notmyfirstname @planet.nl> wrote in news:#iSu2n2cFH A.2644
              @TK2MSFTNGP09.p hx.gbl:[color=blue]
              > Probably in most systems in the world is the decimal point a ","[/color]

              Well yes and no. Much of Europe as you know uses , for the decimal point and . for the thousands
              separator. Now Im not sure about China and India - but if they do then just accounting for population
              alone Id say that most of the world does not. :)

              What really goofs me up is dates. Europe uses d/m while North America uses m/d. So when you
              have something like 21/4 its easy to know the actual date. But when you have someting like 6/8... Aug
              6th or June 8th?


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

              Make your ASP.NET applications run faster

              Comment

              • Cor Ligthert

                #8
                Re: Local Settings and NumberFormat issues

                Kudzu,

                I have no idea how it is in Asia (beside Russia), but how about South and
                Middle America (Where is spoken Spanish and Portugese and in very small
                parts French, English and Dutch), Africa (Important parts speaks beside
                Arabian and own lanugages French and because their colonial background do
                numbers probably as the Portugese). (I am curious what in South Africa is
                used).

                So maybe I would have written countries which use for centurys the arabian
                characters for numbers an have not as own language English.

                About dates and times, from the English speaking countries I am only sure
                from the USA and English speaking Canada that they use MM-dd-yy. PM and AM
                is everywhere in English speaking countries. For the rest I thought it was
                accoording what I wrote above about the used characters dd-MM-yy.

                When I wrote once in past about this, there was somebody, who ws answering
                from Australia that this was the reason they would never buy typical USA
                software anymore.

                However al as far as I know.

                Cor


                Comment

                • Chad Z. Hower aka Kudzu

                  #9
                  Re: Local Settings and NumberFormat issues

                  "Cor Ligthert" <notmyfirstname @planet.nl> wrote in
                  news:eomypP3cFH A.2124@TK2MSFTN GP14.phx.gbl:[color=blue]
                  > I have no idea how it is in Asia (beside Russia), but how about South[/color]

                  Russia very often uses , for decimals and . for thousands. (As your probably know I live in
                  Russia half the year). Im not sure which European countries do as well, but in my travels I see it
                  a lot.
                  [color=blue]
                  > So maybe I would have written countries which use for centurys the
                  > arabian characters for numbers an have not as own language English.[/color]

                  Its not juts arabic numbers (Which are actually Hindi numbers). I have "Arabic" numbers as most
                  refer them to on my system. I got used to them in when I worked in the middle east and just left
                  them.
                  [color=blue]
                  > About dates and times, from the English speaking countries I am only
                  > sure from the USA and English speaking Canada that they use MM-dd-yy.
                  > PM and AM is everywhere in English speaking countries. For the rest I
                  > thought it was accoording what I wrote above about the used characters
                  > dd-MM-yy.[/color]

                  For the most part yes. But the US thinks the whole world uses mm/dd. :)
                  [color=blue]
                  > When I wrote once in past about this, there was somebody, who ws
                  > answering from Australia that this was the reason they would never buy
                  > typical USA software anymore.[/color]

                  Quicken is a good example of this. It cannot handle the dates as it does not use the system
                  settings. ;(


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

                  Develop ASP.NET applications easier and in less time:

                  Comment

                  • ru

                    #10
                    Re: Local Settings and NumberFormat issues

                    On Fri, 17 Jun 2005 20:24:54 +0200, "Cor Ligthert"
                    <notmyfirstname @planet.nl> wrote:
                    [color=blue]
                    >Ru,
                    >
                    >Probably in most systems in the world is the decimal point a ","
                    >
                    >Cor[/color]

                    I know, but when I change it back to "." the problems disappear. This
                    is a Windows XP Pro Dutch system with SP2. Any ideas as to why this
                    may happen?

                    ru

                    Comment

                    • Cor Ligthert

                      #11
                      Re: Local Settings and NumberFormat issues

                      Kudzu,

                      Some things are easy to find in Wikipedia
                      :-)


                      This shows as I always write. Beside the original English speaking countries
                      is the dot as well extremely used as decimal point separator, in what I call
                      forever Coca-Cola cultures. (Cultures that don't have original the Latin and
                      Arabian characters in there main writing system).

                      Beside that we see that countries, long time cultural dominated by foreing
                      countries, use the ones from those. By instance India(England) has a dot
                      seperator, while Indonesia has a comma seperator (Holland). In addition we
                      see that South Africa uses the Dutch system while the official language is
                      English.

                      In correction of my previous message do I see now that Middle America uses
                      the dot.

                      I find this forever interresting stuff. As you see do I like history.

                      Cor




                      Comment

                      • Cor Ligthert

                        #12
                        Re: Local Settings and NumberFormat issues

                        Ru,

                        I am Dutch and I know that in our country as well Dutch as English operating
                        systems are used.

                        However if you want to use the comma separator on an English system than
                        you can change (not advisable) the settings of that. Because English systems
                        are more and more only servers is that mostly not important (as I wrote not
                        advisable), admins use automatically the dot when that is needed on those
                        servers, that is in my opinion the case for most Dutch users of English
                        operating systems (used in International environments) .

                        I have not much experience where this change of settings can go wrong. One
                        situation I know for sure, which is W98/Me. Setting the culture setting on
                        those systems has no sense for dotNet. In W98/Me you have to change the
                        keyboard parameters for that (An old expirience I don't know if that is
                        changed with latest service packs).

                        I hope this gives some help. However some more information from you, than
                        some words in a message would probably give the ones who want to help you
                        more change to do that.

                        My question was, did you use culture settings in your program(s), I have not
                        seen any answer on that.

                        I hope this helps,

                        Cor


                        Comment

                        • ru

                          #13
                          Re: Local Settings and NumberFormat issues

                          On Sat, 18 Jun 2005 09:19:33 +0200, "Cor Ligthert"
                          <notmyfirstname @planet.nl> wrote:
                          [color=blue]
                          >Ru,
                          >
                          >I am Dutch and I know that in our country as well Dutch as English operating
                          >systems are used.
                          >
                          >However if you want to use the comma separator on an English system than
                          >you can change (not advisable) the settings of that. Because English systems
                          >are more and more only servers is that mostly not important (as I wrote not
                          >advisable), admins use automatically the dot when that is needed on those
                          >servers, that is in my opinion the case for most Dutch users of English
                          >operating systems (used in International environments) .
                          >
                          >I have not much experience where this change of settings can go wrong. One
                          >situation I know for sure, which is W98/Me. Setting the culture setting on
                          >those systems has no sense for dotNet. In W98/Me you have to change the
                          >keyboard parameters for that (An old expirience I don't know if that is
                          >changed with latest service packs).
                          >
                          >I hope this gives some help. However some more information from you, than
                          >some words in a message would probably give the ones who want to help you
                          >more change to do that.
                          >
                          >My question was, did you use culture settings in your program(s), I have not
                          >seen any answer on that.
                          >
                          >I hope this helps,
                          >
                          >Cor[/color]

                          Hi Cor,

                          the only culture settings I use is like this:
                          Dim strDateFormat As String =
                          CultureInfo.Cur rentCulture.Dat eTimeFormat.Cur rentInfo.ShortD atePattern.ToSt ring

                          to format Dates to the users system.
                          But that code is independent of the CInt code.

                          btw, I just tested my system, which is an English/US box with XP Pro
                          SP2, and when I change the "." to "," my program also crashes.
                          I never had this before, I know because I tested it a couple of months
                          back. Very weird.

                          ru

                          Comment

                          • Chad Z. Hower aka Kudzu

                            #14
                            Re: Local Settings and NumberFormat issues

                            ru <ur@sx3all.be > wrote in news:6bg7b1pre1 65g7707vn10rk70 667dnv8vg@4ax.c om:[color=blue]
                            > I know, but when I change it back to "." the problems disappear. This
                            > is a Windows XP Pro Dutch system with SP2. Any ideas as to why this
                            > may happen?[/color]

                            I didnt see the original message, but its usually caused by software not using system routines for
                            parsing and hard coding to the .


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

                            Empower ASP.NET with IntraWeb

                            Comment

                            • ru

                              #15
                              Re: Local Settings and NumberFormat issues

                              On Sat, 18 Jun 2005 10:40:33 +0300, "Chad Z. Hower aka Kudzu"
                              <cpub@hower.org > wrote:
                              [color=blue]
                              >ru <ur@sx3all.be > wrote in news:6bg7b1pre1 65g7707vn10rk70 667dnv8vg@4ax.c om:[color=green]
                              >> I know, but when I change it back to "." the problems disappear. This
                              >> is a Windows XP Pro Dutch system with SP2. Any ideas as to why this
                              >> may happen?[/color]
                              >
                              >I didnt see the original message, but its usually caused by software not using system routines for
                              >parsing and hard coding to the .[/color]

                              I'm not aware of bypassing the system routines for parsing - how does
                              one do that :) Can you give me an example?

                              The code causing my problem is pretty basic stuff:

                              int100 = CInt(txt100.Tex t)

                              int100 is an integer
                              txt100 is a textbox displaying an integer variable: there's no decimal
                              separator involved, so I don't know why this is raising an error.

                              Changing the code to:
                              int100 = Integer.Parse(t xt100History.Te xt,
                              NumberStyles.Al lowDecimalPoint )
                              cleared the error.

                              Another thing I discovered was that the IsNumeric function also didn't
                              work properly. The following code would always return false, no matter
                              what key was pressed:

                              Private Sub txtScore_TextCh anged(ByVal sender As Object, ByVal e As
                              System.EventArg s) Handles txtScore.TextCh anged
                              If IsNumeric(txtSc ore.Text) = False Then
                              txtScore.Text = ""
                              End If
                              'End Sub

                              I now notice that only parsing of variables from the form itself,
                              displayed by labels or textboxes, is causing troubles. I just tested a
                              conversion from an integer declared in code to a double to a string
                              without errors.

                              ru



                              Comment

                              Working...