Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integers and Textfields.

 
mark geroso
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
How do I make an integer value show up in a textfield? Certain user actions can increment the integer value, I'd also like the integer in the textfield to update...
 
Parth Bhatt
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The value that you read from the textfield will always be a string. And to increment the value read you will always need an int.

So in this case The obvious solution would be : Whenever you want to increment the contents of the text field,

1)read it into a string


2)Convert it into an int


3)Put the new incremented value into the textfield


NOTE : In step (2) if the contents of the textfield is not integer, it will throw a NumberFormatException. So beter handle it.
 
mark geroso
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I kept getting tripped up because the value wasn't updating, didn't think about extracting the value from the textfield first.
I'll give it a try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic