# Formatting a String with three int's

**URL:** <https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [September 6, 2026, 12:41pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186 "2026-09-06T12:41:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michellembrodeur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michellembrodeur](https://forums.unrealengine.com/u/Michellembrodeur)\
**Post date:** [September 6, 2026, 12:41pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/1 "2026-09-06T12:41:24Z")

</div>

I am using UnrealEngine and Rider for the C++ side.

Morning all, Hope I can ask this here.

I am following a instructor for a course but cannot get this resolved because its not part of the course.

So here is his original code.

void FInv\_LabelNumberFragment::Assimilate(UInv\_CompositeBase\* Composite) const  
{  
FInv\_InventoryItemFragment::Assimilate(Composite);

if (!MatchesWidgetTag(Composite)) return;

UInv\_Leaf\_LabeledValue\* LabelValue = Cast\<UInv\_Leaf\_LabeledValue\>(Composite);  
if (!IsValid(LabelValue)) return;

LabelValue-\>SetText\_Label(Text\_Label, bCollapseLabel);

FNumberFormattingOptions Options;  
Options.MinimumFractionalDigits = MinFractionalDigits;  
Options.MaximumFractionalDigits = MaxFractionalDigits;

LabelValue-\>SetText\_Value(FText::AsNumber(Value, &Options), bCollapseValue);  
}

it displays a float value called Value in a item description widget. It works no problem.

 ![tool](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/f/24f0251e6ca37b2bfd9b161a1fc3b20708ed44ea.png)

Now I want to display a 2d6 +3 type of value.

NumberOfDice d TypeOfDice + ExtraDamage.

So this is my code, but cannot figure out to properly write the code.

void FInv\_DamageNumberFragment::Assimilate(UInv\_CompositeBase\* Composite) const  
{  
FInv\_InventoryItemFragment::Assimilate(Composite);  
if (!MatchesWidgetTag(Composite)) return;

UInv\_Leaf\_LabeledValue\* LabelValue = Cast\<UInv\_Leaf\_LabeledValue\>(Composite);  
if (!IsValid(LabelValue)) return;

LabelValue-\>SetText\_Label(Text\_Label, bCollapseLabel);

FNumberFormattingOptions Options;

\*//LabelValue-\>SetText\_Value(FText::AsNumber(Value, &Options), bCollapseValue);  
\*  
LabelValue-\>SetText\_Value(FText::FromString( FString::Printf(TEXT(“%i d %i + %i”), GetNumberOfDice() , GetTypeOfDice(), GetExtraDamage(), &Options), bCollapseValue));

}

this is the line to fix.

LabelValue-\>SetText\_Value(FText::FromString( FString::Printf(TEXT(“%i d %i + %i”), GetNumberOfDice() , GetTypeOfDice(), GetExtraDamage(), &Options), bCollapseValue));

any help would be great. Been at this for days.

---

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [September 6, 2026, 2:17pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/2 "2026-09-06T14:17:45Z")

</div>

Found this post about using FText::Format on a String Table

> [@\[Solved\] Using FText::Format with TexBlock Text from StringTable](https://forums.unrealengine.com/t/solved-using-ftext-format-with-texblock-text-from-stringtable/145326/2):
>
> From my page on [localizing UIs in Unreal](http://benhumphreys.ca/unreal/ui-localization/#do-use-formattext), you can use FFormatNamedArgs and pass that into FText::Format: int32 Value = 150; FText FormatInput = FText::FromStringTable("MyTable", "HealthFormat"); FFormatNamedArguments Args; Args.Add("HealthValue", Value); FText FormattedText = FText::Format( FormatInput, Args );

In your case, the code (not tested) could be something like this:

```auto
int32 Value1 = 1;
int32 Value2 = 2;
int32 Value3 = 3;

FText FormatInput = FText::FromString("{Int1}d{int2} +{int3}"); // 2d6 +3

FFormatNamedArguments Args;
Args.Add("Int1", Value1);
Args.Add("Int2", Value2);
Args.Add("Int3", Value3);
FText FormattedText = FText::Format( FormatInput, Args );

```

---

<div class="post-metadata">

**Author:** ![Michellembrodeur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michellembrodeur](https://forums.unrealengine.com/u/Michellembrodeur)\
**Post date:** [September 6, 2026, 3:27pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/3 "2026-09-06T15:27:42Z")

</div>

ok how would i fix the last line to set

LabelValue-\>SetText\_Value(FText::FromString(FormatedText, &Options), bCollapseValue);

i have to pass it like to original line of

```auto
LabelValue->SetText_Value(FText::AsNumber(Value, &Options), bCollapseValue);

with Replacing Value with FormatedText?

```

---

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [September 6, 2026, 4:49pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/4 "2026-09-06T16:49:08Z")

</div>

Replace the FText input parameter with `FormattedText` like so:

```auto
LabelValue->SetText_Value(FormattedText, bCollapseValue);

```

Final code could be something like this:

```auto
FText FormatInput = FText::FromString("{DiceCount}d{DiceType} +{ExtraDamage}");

FFormatNamedArguments Args;
Args.Add("DiceCount", GetNumberOfDice());
Args.Add("DiceType", GetTypeOfDice());
Args.Add("ExtraDamage", GetExtraDamage());

FText FormattedText = FText::Format( FormatInput, Args );

LabelValue->SetText_Value(FormattedText, bCollapseValue);

```

---

<div class="post-metadata">

**Author:** ![Michellembrodeur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michellembrodeur](https://forums.unrealengine.com/u/Michellembrodeur)\
**Post date:** [September 6, 2026, 9:40pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/5 "2026-09-06T21:40:18Z")

</div>

Close but AsNumber needs the first argument as a int or Uint or float.

---

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [September 7, 2026, 6:08am UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/6 "2026-09-07T06:08:10Z")

</div>

> [@Michellembrodeur](#):
>
> AsNumber needs the first argument as a int or Uint or float

You don’t need `FText::AsNumber()` anymore. Replace it with `FText::Format()` like so:

```auto
LabelValue->SetText_Value(FText::Format(FormatInput, Args), bCollapseValue)

```

---

<div class="post-metadata">

**Author:** ![Michellembrodeur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michellembrodeur](https://forums.unrealengine.com/u/Michellembrodeur)\
**Post date:** [September 7, 2026, 12:01pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/8 "2026-09-07T12:01:56Z")

</div>

thank you so very much.

---

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [September 7, 2026, 12:02pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/9 "2026-09-07T12:02:25Z")

</div>

Fixed?

---

<div class="post-metadata">

**Author:** ![Michellembrodeur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Michellembrodeur](https://forums.unrealengine.com/u/Michellembrodeur)\
**Post date:** [September 7, 2026, 12:02pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/10 "2026-09-07T12:02:42Z")

</div>

yes

---

<div class="post-metadata">

**Author:** ![Extrone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/extrone/32/906554_2.png) [@Extrone](https://forums.unrealengine.com/u/Extrone)\
**Post date:** [September 7, 2026, 12:05pm UTC](https://forums.unrealengine.com/t/formatting-a-string-with-three-ints/2763186/11 "2026-09-07T12:05:19Z")

</div>

Nice, glad I could help. Please mark the post that helped fix the issue as Solution so others could find it. If none of the posts are the solution, please post the solution yourself, thanks.
