473,395 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Changing data type of textbox?

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.
Sep 19 '07 #1
5 2422
nickyeng
254 100+
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.
Expand|Select|Wrap|Line Numbers
  1. try{
  2.     float f1 = Float.parseFloat(str);
  3. }
  4. catch(NumberFormatException nfe) { 
  5.    // catch the exception if the String entered is not numeric values.
  6. }
  7.  
it convert String to float.

from
Nick
Sep 19 '07 #2
Still very confused.
I need to get from the txtGPA (name of my textbox), and store it as a float in my array.

I'm new to Java so any help is appreciated.
Sep 19 '07 #3
nickyeng
254 100+
Expand|Select|Wrap|Line Numbers
  1.  
  2. float[] arr = new float[3];
  3. // use the method to get the value of textbox and parse to float
  4. float[0] = Float.parseFloat(textGPA.getValue());
  5.  
  6.  
something like that...
Sep 19 '07 #4
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.

float floatValue = Float.parseFloat(txtGPA.getText());



parseFloat(String str) is the static method of class Float
Sep 19 '07 #5
float floatValue = Float.parseFloat(txtGPA.getText());



parseFloat(String str) is the static method of class Float


Thank you so much! That all worked great.
Sep 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
1
by: Paul M. Frazier, Ph.D. | last post by:
I am writing a user information update page and I populate the form on Page_Load with the current values of the user's name, etc. When I change the text in one of the textbox controls (e.g.,...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. I created a simple ASP.NET web form, a simple SQL...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
4
by: weg22 | last post by:
Hi all, I'm developing a Visual Basic 2005 application to communicate with an I2C device. I recently decided to add an i2c status bar. The status bar is just a textbox with the following...
4
by: John Kotuby | last post by:
Hi all, I have a simple user-form which accepts contact and profile information for the user to edit and save. All the textboxes are working fine and displaying the expected data, both when the...
1
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name...
1
by: gandhi.vishal | last post by:
Hello, I have an issue. I'm not seeing the reportviewer data at all. The column names come up fine but there is no data in the report table. Here is what I'm doing I created a dataset with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.