|
-
March 13th, 2011, 02:37 PM
#1
[RESOLVED] How to get a float out of a textbox number ?
Given a textbox containing the number (text) '123.234345456567', how do I get this converted to a float variable in the underlying c# code ?
mpliam
-
March 14th, 2011, 03:06 AM
#2
Re: How to get a float out of a textbox number ?
Code:
float f = float.Parse(TextBox1.Text);
But this one will throw an exception if the input is not a valid float.
Instead use
Code:
float f;
bool valid = float.TryParse(TextBox1.Text, out f);
-
March 14th, 2011, 03:04 PM
#3
Re: How to get a float out of a textbox number ?
Thanks, Danny. I figured it out. See my previous post for an explanation of the problem I was having.
http://www.codeguru.com/forum/showthread.php?t=509782
mpliam
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
|