Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to convert values from a textBox to float,

I tried

floar number = float.Parse(textBox.text);

dont works if the textbox contain "." (the whole idea of doing this)
Posted
Comments
PIEBALDconsult 29-Aug-15 0:35am    
So why not use a NumericUpDown instead?
Sergey Alexandrovich Kryukov 29-Aug-15 1:25am    
Good idea! However, it only works for values arranged on uniform intervals, won't work for arbitrary values.
—SA
PIEBALDconsult 29-Aug-15 11:45am    
Sure they do, you can type in anything you want.
Sergey Alexandrovich Kryukov 29-Aug-15 21:12pm    
As far as I remember, it will be rounded to nearest value from the finite set of allowed values, otherwise it would defeat the purpose. This input type is very safe, does not require validation.
—SA
Mehdi Gholam 29-Aug-15 1:26am    
float.Parse("110.9") works perfectly fine.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900