|
-
May 14th, 2004, 10:27 PM
#1
Thread Starter
Junior Member
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
-
May 15th, 2004, 03:30 AM
#2
Hyperactive Member
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
-
May 15th, 2004, 06:08 PM
#3
Thread Starter
Junior Member
Thanks Sgt-Peppa the workaround works just fine!!
-
May 19th, 2004, 09:44 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|