# Bug or bad code? Can't display the length of a variable

**URL:** <https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449>\
**Category:** Questions about Thunkable X\
**Created:** [December 31, 2023, 2:01pm UTC](https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449 "2023-12-31T14:01:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grant.mccallum](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/grant.mccallum/32/210541_2.png) [@grant.mccallum](https://community.thunkable.com/u/grant.mccallum)\
**Post date:** [December 31, 2023, 2:01pm UTC](https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449/1 "2023-12-31T14:01:59Z")

</div>

Hi all,

I am trying to generate a random number and display this number in a label.

In the length label below, I would like to display the length of the randomly generated number from the variable.

Screen:

 ![lengthnumber screen](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/0105219dae361f064a999b11b6a60644b664a2be.png)

Blocks:

 ![lengthnumber blocks](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/a/dae045acb37ae2066bd22714485e4800eb98b1a2.png)

Link: [Project Link](https://x.thunkable.com/projects/6591710b5c4be931f6e8bec5/538bf9f6-2951-4879-92ff-28639cd25b10/)

The text in my “Length” label remains blank when I start this app and will not display the length of the variable string.

Strangely, this works fine if I make it read the length from the label rather than the variable but this won’t work for my purposes.

All help appreciated!

---

<div class="post-metadata">

**Author:** ![steve\_synopsis](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@steve\_synopsis](https://community.thunkable.com/u/steve_synopsis)\
**Post date:** [December 31, 2023, 2:37pm UTC](https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449/2 "2023-12-31T14:37:25Z")

</div>

Hi,

Since an integer is technically a number, Thunkable needs it to be converted to text first become you can get the length.

There are various ways, but I just tried this and it works.

 ![2023-12-31 10 35 27](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/d/8d4d79b4a5f35d851b27cef8a714ecf92f3fa9ff.png)

![2023-12-31 10 36 56](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/1/91bd68a43223b0372ed1ef1301f981cea49dd5fe.png)

---

<div class="post-metadata">

**Author:** ![grant.mccallum](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/grant.mccallum/32/210541_2.png) [@grant.mccallum](https://community.thunkable.com/u/grant.mccallum)\
**Post date:** [December 31, 2023, 2:40pm UTC](https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449/3 "2023-12-31T14:40:19Z")

</div>

Thanks Steve, this is really helpful

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [March 30, 2024, 2:41pm UTC](https://community.thunkable.com/t/bug-or-bad-code-cant-display-the-length-of-a-variable/2764449/4 "2024-03-30T14:41:10Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
