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

**URL:** https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118
**Category:** Questions about Thunkable X
**Tags:** firebase
**Created:** [October 22, 2020, 6:01am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118 "2020-10-22T06:01:47Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 6:01am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/1 "2020-10-22T06:01:47Z")

</div>

Hi, I am making an app that requires adding a certain number of points equal to the number given in a text input box. Now that’s not possible because text input converts it into a string. Please answer if you know any solution!

---

<div class="post-metadata">

### Author: ![KaneoheKid](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@KaneoheKid](https://community.thunkable.com/u/KaneoheKid)
#### Post date: [October 22, 2020, 7:06am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/2 "2020-10-22T07:06:33Z")

</div>

Try the following:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/7/57411b794cc4315914c341f984f9857924ae2b9d.png)

as long as you enter a number, it will work. So, it would be best if you use “keyboard type” NUMERIC from the advanced features for the text box.

KK

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 7:09am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/3 "2020-10-22T07:09:15Z")

</div>

But the problem is that when I push it to firebase, it turns it into a string ☹

---

<div class="post-metadata">

### Author: ![KaneoheKid](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@KaneoheKid](https://community.thunkable.com/u/KaneoheKid)
#### Post date: [October 22, 2020, 7:18am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/4 "2020-10-22T07:18:52Z")

</div>

That should not be a problem. If you are using the value in your app, when you retrieve the value from firebase, you will need to do the same thing, add zero to the variable or multiply by one.

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 8:38am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/5 "2020-10-22T08:38:09Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/9/b9e2046d516e7c1b109b4e113a77de61de070c7d.png)

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 8:39am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/6 "2020-10-22T08:39:48Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/1/e1a0769f076250d9865e15b103ceaecfac41d146.png)  
before adding

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 3:44pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/7 "2020-10-22T15:44:58Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/f/dfa5e011839fa120355089ed7b4db70d57b569da.png)  
I converted the label circled to the value, it didn’t work, giving a NaN value ☹

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 22, 2020, 4:01pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/8 "2020-10-22T16:01:36Z")

</div>

In your blocks screenshot, you’re adding a text string to a text string. Where are you converting to a number by adding zero?

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 4:02pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/9 "2020-10-22T16:02:32Z")

</div>

yeah that’s my question, do you know how to convert it?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 22, 2020, 4:02pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/10 "2020-10-22T16:02:54Z")

</div>

The last block should say “from Point Value - Add A Reading set Text to app TotalPoint - AddAReading + from Point Value - Add A Reading get Text **+ 0** ”

Here’s an example: [Trying to add number from Text Input - #2 by actech](http://community.thunkable.com/t/trying-to-add-number-from-text-input/600837/2)

Use the + and 0 blocks in the Math drawer:

![Screen Shot 2020-10-22 at 9.03.39 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/4/34351dddea5a21c6e533c78d3131c7adbbdd8304.png)

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 4:07pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/11 "2020-10-22T16:07:58Z")

</div>

Didn’t work ☹

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 4:09pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/12 "2020-10-22T16:09:15Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/24383432e06c270087076a6e49de836c128188b1.png)  
This is what I changed(don’t mind the Reading of Petrol it’s the text input thing)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 22, 2020, 5:05pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/13 "2020-10-22T17:05:03Z")

</div>

Are you still getting “NaN”?

What happens when you check the values of the two green error blocks using labels? What are those values?

If you want to share the link to your project, I can take a look at it.

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 22, 2020, 5:07pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/14 "2020-10-22T17:07:18Z")

</div>

Sure here is the link! [https://x.thunkable.com/copy/1ec7b11ff06df4010279c1e4752678ec](https://x.thunkable.com/copy/1ec7b11ff06df4010279c1e4752678ec)

keep in mind that the ui hasn’t been worked on

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 22, 2020, 5:54pm UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/15 "2020-10-22T17:54:17Z")

</div>

You only converted ONE of the two strings to a number. Originally, you had string+string=NaN. Now you have string+number=NaN. You need number+number=number.

Add a **+ 0** here:

 ![Screen Shot 2020-10-22 at 10.51.33 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/5/55691bf8ce44d16c888498347314728b166e469e.png)

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 23, 2020, 2:11am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/16 "2020-10-23T02:11:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/8/08a53a2f611df95428effbe0eb200f94e870d5c9.png)  
it didn’t work ☹

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 23, 2020, 2:11am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/17 "2020-10-23T02:11:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/a/1a787bacd52dcb809b62bdce458f40ac36126b75.png)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 23, 2020, 2:24am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/18 "2020-10-23T02:24:10Z")

</div>

Yep, that should have worked. If you set text labels to the two variable values and to their values with zero added, what do you get?

---

<div class="post-metadata">

### Author: ![rohan.narahari35ad](https://avatars.discourse-cdn.com/v4/letter/r/c37758/32.png) [@rohan.narahari35ad](https://community.thunkable.com/u/rohan.narahari35ad)
#### Post date: [October 23, 2020, 2:36am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/19 "2020-10-23T02:36:46Z")

</div>

It gave a NaN value again ☹

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [October 23, 2020, 4:01am UTC](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118/20 "2020-10-23T04:01:12Z")

</div>

> [@tatiang](#):
>
> Yep, that should have worked. If you set text labels to the two variable values and to their values with zero added, what do you get?

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](http://community.thunkable.com/t/math-help-formula-not-working/917769/12)) 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:

 ![Screen Shot 2020-10-22 at 8.57.26 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/e/be64f395a1da5838a2956577ff290bf93ea5e3b4.png)

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.

[Next page](https://community.thunkable.com/t/convert-text-input-to-int-how-to-make-numeric-input-that-can-be-used-for-math/921118.md?page=2)
