Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. converting string to decimal shows error

converting string to decimal shows error

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vipin d
    wrote on last edited by
    #1

    System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Decimal.Parse(String s, IFormatProvider provider) at System.Convert.ToDecimal(String value) at test.Button1_Click(Object sender, EventArgs e) in e:\MyProject\DOTNET2005\HR2005\test.aspx.cs:line 30

    All I ever wanted is what others have....
    CrazySanker

    R 1 Reply Last reply
    0
    • V Vipin d

      System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Decimal.Parse(String s, IFormatProvider provider) at System.Convert.ToDecimal(String value) at test.Button1_Click(Object sender, EventArgs e) in e:\MyProject\DOTNET2005\HR2005\test.aspx.cs:line 30

      All I ever wanted is what others have....
      CrazySanker

      R Offline
      R Offline
      Roland Bar
      wrote on last edited by
      #2

      FormatException in System.Convert.ToDecimal(String value) means: value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol. Check if: - the String to convert has no invalid chars (letters etc.) - the String has the right delimiter for the used local settings (you can set the Culture with Convert.ToDecimal Method (String, IFormatProvider) ). Maybe just put the string before converting to the trace so you can see the value used (or set a breakpoint). Hope that helps Roland


      Hi! I'm a signature virus. Copy me into your sig file and help me spread!

      Follow your Euro notes in their tracks

      V 1 Reply Last reply
      0
      • R Roland Bar

        FormatException in System.Convert.ToDecimal(String value) means: value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol. Check if: - the String to convert has no invalid chars (letters etc.) - the String has the right delimiter for the used local settings (you can set the Culture with Convert.ToDecimal Method (String, IFormatProvider) ). Maybe just put the string before converting to the trace so you can see the value used (or set a breakpoint). Hope that helps Roland


        Hi! I'm a signature virus. Copy me into your sig file and help me spread!

        Follow your Euro notes in their tracks

        V Offline
        V Offline
        Vipin d
        wrote on last edited by
        #3

        hi, Thank you for your reply I detetct the problem. It was,in default my machine support "," instead of "." in decimal values. How can i slove it??? i upgraded asp.net1.0 application to asp.net2.0. In my applcation I am using convert.toDecimal function in numerous place. how i solve it??

        All I ever wanted is what others have....
        CrazySanker

        R 1 Reply Last reply
        0
        • V Vipin d

          hi, Thank you for your reply I detetct the problem. It was,in default my machine support "," instead of "." in decimal values. How can i slove it??? i upgraded asp.net1.0 application to asp.net2.0. In my applcation I am using convert.toDecimal function in numerous place. how i solve it??

          All I ever wanted is what others have....
          CrazySanker

          R Offline
          R Offline
          Roland Bar
          wrote on last edited by
          #4

          string a = "12.85"; decimal da = System.Convert.ToDecimal(a, System.Globalization.CultureInfo.InvariantCulture); string b = "12,85"; decimal db = System.Convert.ToDecimal(b, new System.Globalization.CultureInfo("de-DE")); hope that helps Roland


          Hi! I'm a signature virus. Copy me into your sig file and help me spread!

          Follow your Euro notes in their tracks

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups