# String to int Conversion

**URL:** <https://forums.unrealengine.com/t/string-to-int-conversion/469683>\
**Category:** Blueprint\
**Tags:** string, conversion, integer, unreal-engine, Blueprint, question\
**Created:** [August 13, 2020, 10:19am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683 "2020-08-13T10:19:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 13, 2020, 10:19am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/1 "2020-08-13T10:19:31Z")

</div>

So, for some reason, when I’m trying to convert String value to Int value, last part of the number just dissapears.

I am trying to get resolution from UI. It’s a Text formated as “ **{Width}x{Height}** ” (for example “ **1280x720** ”). I then convert it to string (it’s still “ **1280x720** ”), then I use Split node to split the string into two separate strings at the “ **x** ” (it returns two strings “ **1280** ” and “ **720** ”). Everything fine thus far. Then I use ToInt node, to convert both strings to integers and here’s the problem: for some reason the first string only converts to the first digit of the number, while the second one converts fine. So I have the outputs of **1** and **720** , instead of **1280** and **720**.

Why is this happening and what do I do?

---

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 13, 2020, 11:01am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/2 "2020-08-13T11:01:58Z")

</div>

Had to work around this and just get resolution I need from the array of fullscreen resolutions.

So basically not to use the conversion to numbers if String is converted from Formated Text, because Format Text outputs a dressed string, which has commas in it. (Internally it was something like “ **1,280** ”, not “ **1280** ”).

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [August 13, 2020, 11:02am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/3 "2020-08-13T11:02:53Z")

</div>

Did you connect all the values right? Here’s what I have and it works:

 ![310067-subs.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/f/e/9fee35c14f5ab9b93d89433fb3639da459632fc0.png)

---

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 13, 2020, 7:08pm UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/4 "2020-08-13T19:08:37Z")

</div>

I used Split not a substring. Also, try converting from Text to String and then do your function. Does it still work? Anyway I found what works for me and probably even better.

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [August 13, 2020, 7:20pm UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/5 "2020-08-13T19:20:16Z")

</div>

It works with Text To String, and Split works too, and that’s a lot easier, in fact. Thank you! I didn’t know about the Split node.

---

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 14, 2020, 8:15am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/6 "2020-08-14T08:15:38Z")

</div>

Then does it work after Format Text node?

---

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 14, 2020, 8:16am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/7 "2020-08-14T08:16:22Z")

</div>

That’s all written in my question and I speculate, the problem is with dressed strings.

---

<div class="post-metadata">

**Author:** ![TRI99ER](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TRI99ER](https://forums.unrealengine.com/u/TRI99ER)\
**Post date:** [August 15, 2020, 10:21am UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/8 "2020-08-15T10:21:46Z")

</div>

I explain the problem in my answer above. Thanks for trying to help anyway.

---

<div class="post-metadata">

**Author:** ![AndyNB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AndyNB](https://forums.unrealengine.com/u/AndyNB)\
**Post date:** [October 8, 2023, 3:28pm UTC](https://forums.unrealengine.com/t/string-to-int-conversion/469683/9 "2023-10-08T15:28:44Z")

</div>

Incase it helps anyone else… I had a the same problem. It turned out (like [TRI99ER\_) my numbers were coming from a Widget Input Text field which was adding a comma to any number over 999. (so I was getting “1,280”) When I then converted the text to a string, then to a Value, I just got the first part of the number, ie just the 1. If the number is less than 999, it works perfectly. I had to use the blueprint shown above just to strip out the “,” for any number over 999 first. Thanks Tuerer!

I spent a lot of time trying to work out if I could have just a simple widget “numeric” input field that wouldn’t do this, but I never found one. Even if you choose “numeric” in the fields details.
