Results 1 to 4 of 4

Thread: Ask textbox get numbers...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    24

    Ask textbox get numbers...

    Hi all


    Anyone knows how to convert strings to numbers...

    I got this textbox to prompt a user for a number. I use function todouble to convert it to a number but if a user enters 14.5 i get 145 in the variable....


    How do i get 14.5 or 14,5 ?
    I mean how do i get the right number?


    double mynumber= Convert.ToDouble(Txttextbox1.Text);

    Doesn't do the job right....

    Ty in advance

  2. #2
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    It seems like the Double parser only looks for "," and not ".".

    If you enter the value with a "," it works.

    So heres a workaround,

    Code:
    			string myString ="14.5";
    			myString = myString.Replace(".",",");
    			double myNumber = Double.Parse(myString);
    			Console.WriteLine(myNumber.ToString());
    			Console.ReadLine();
    Sorry, I dont have an explanation, just if you need a quick workaround,...

    HTH, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    24
    Thanks Sgt-Peppa the workaround works just fine!!

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    haha imagina quem sou
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width