How do I convert text (String) from a textbox to a float. I have a user textbox that is entering a number. It is entering as a String. Need it to be a float.
Changing data type of textbox?
Collapse
X
-
Originally posted by kjkrudhHow do I convert text (String) from a textbox to a float. I have a user textbox that is entering a number. It is entering as a String. Need it to be a float.Code:try{ float f1 = Float.parseFloat(str); } catch(NumberFormatException nfe) { // catch the exception if the String entered is not numeric values. }
from
Nick -
Originally posted by kjkrudhHow do I convert text (String) from a textbox to a float. I have a user textbox that is entering a number. It is entering as a String. Need it to be a float.
float floatValue = Float.parseFloa t(txtGPA.getTex t());
parseFloat(Stri ng str) is the static method of class FloatComment
Comment