Convert Text Input to int/ How to make numeric input that can be used for Math

I’m not sure you’re understanding what I suggested. I have a hard time believing that the math functions in Thunkable are broken (asin notwithstanding) or that adding zero to a text string doesn’t convert it to a number.

So the only other thing that could be causing “NaN” to appear is that your text strings are not valid numbers. For example, it’s possible that having a space or a punctuation mark within the string will invalidate it even when adding zero to it.

So the next step should be to create two labels on the screen. They should be different label components but I’ve shown them as the same in this screenshot:

The idea is to generate two results, both bookended by Xs. So for example, if you see something like…

X5489X

…then you know it’s a valid string to convert to a number by adding zero to it.

But if you see…

X 5489X then there’s potentially a problem because your string is " 5489" with a leading space.

And if you see…

XX then you know the database Get block failed because your string is “”.

Also, what are your green error blocks showing if you add them to labels so you can see their value?

This type of troubleshooting is really common with Thunkable (and any programming language/environment) so if you’re new to Thunkable, these are good skills to start using.

1 Like