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. General Programming
  3. C#
  4. Single.Parse(string) problem...

Single.Parse(string) problem...

Scheduled Pinned Locked Moved C#
helpcsharp
2 Posts 1 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.
  • L Offline
    L Offline
    Luc Bergeron
    wrote on last edited by
    #1

    Hello everyone, i'm quite new to this c# world so please bear with me :) So I have this form and in it I have an editbox in which I must enter a number, in the following form : 119.43. Now, I need this string to be converted to float. Here's how I do it : float p = System.Single.Parse(prixS); BUT, I always get a string not properly formatted exception. I tried entering the price with a comma, no can do. Than I tried this : prixF = (float)System.Single.Parse(prix, System.Globalization.NumberStyles.AllowDecimalPoint| System.Globalization.NumberStyles.AllowTrailingWhite| System.Globalization.NumberStyles.AllowLeadingWhite); But again same error. Can someone please help me on this. Thanks for any help. Luc.

    L 1 Reply Last reply
    0
    • L Luc Bergeron

      Hello everyone, i'm quite new to this c# world so please bear with me :) So I have this form and in it I have an editbox in which I must enter a number, in the following form : 119.43. Now, I need this string to be converted to float. Here's how I do it : float p = System.Single.Parse(prixS); BUT, I always get a string not properly formatted exception. I tried entering the price with a comma, no can do. Than I tried this : prixF = (float)System.Single.Parse(prix, System.Globalization.NumberStyles.AllowDecimalPoint| System.Globalization.NumberStyles.AllowTrailingWhite| System.Globalization.NumberStyles.AllowLeadingWhite); But again same error. Can someone please help me on this. Thanks for any help. Luc.

      L Offline
      L Offline
      Luc Bergeron
      wrote on last edited by
      #2

      My freakin' bad :zzz: :mad: :(( :laugh: When fetching the text from the TextBox, I was using this.PriceEdit.ToString()... Ah ah ah !!! Wrong... This got me some undesired text in the string. I found that I need to use the TextBox.Text to access the text entered !!! Luc.

      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