View Full Version : Converting Text into an Integer?

04 April 2008, 02:00 AM
Im sure this is a easy problem for you guys to solve, but how do I convert text from a edittext box into an integer to be read as numbers?

For example, here is my code:
edittext txtNthFrame "Every Nth Frame:" FieldWidth:30 pos:[10, 120]

rendNThFrame = txtNthFrame

The error message Im getting is that the rendNthFrame is not a integer, even when I enter a number into the edittext box. What variable am I missing or can use to convert the edittext box to read as a integer and not text??


04 April 2008, 02:32 AM
Hi ! you probably should use a spinner for that.

but to convert text, you can use the 'as' keyword.

rendNThFrame = txtNthFrame.text as integer

04 April 2008, 03:10 AM
You rule the planet! Thanks man!

04 April 2008, 04:37 AM
Alternatively, consider using a spinner for the value, text fields are not very useful for number entry as the user could enter ANYTHING and crash the code unless you tested to make sure the string entered IS a number...

CGTalk Moderation
04 April 2008, 04:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.