|
-
Jul 2nd, 2004, 01:52 PM
#1
Thread Starter
Frenzied Member
String to integer{resolved}
I am trying to do something like this:
String text = TextBox1.getText();
int number = (int)text;
It is not letting me cast a string to an integer.
Can anyone tell me how to do this?
Last edited by System_Error; Jul 2nd, 2004 at 03:15 PM.
-
Jul 2nd, 2004, 02:35 PM
#2
Dazed Member
Of course you can't cast a string to an integer. Use
int i = Integer.parseInt(s); where s is a String reference.
Last edited by Dilenger4; Jul 2nd, 2004 at 02:43 PM.
-
Jul 2nd, 2004, 02:40 PM
#3
Dazed Member
Then you can go back from an int to a String.
int i = Integer.parseInt(s);
String s2 = String.valueOf(i);
Last edited by Dilenger4; Jul 2nd, 2004 at 02:43 PM.
-
Jul 2nd, 2004, 03:14 PM
#4
Thread Starter
Frenzied Member
I really hate making dumb mistakes!!
Thank you
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
|