How to increment a string variable with 001 002 003


for my workflow i had to extract a number from a mail per regex and then store it in a string variable like for example “9115681”. Now i am within a loop and i have to determine that in every loop the number is increasing, starting with 001. For example the first run is creating the number 9115681001, then 9115681002, 9155681003, …004, …005, …, …999.

Do you have a idea how i can solve this?

(Cint(“001”) + 1).toString.PadLeft(3,"0"c)

And Also:


Hi @Novistic


Count → Integer type Variable

You can increment the variable using assign activity

Use Assign activity
LHS → Count
RHS → Count+1




Thank you so much for your help,

The problem i see with this solution is that if the loop hits 10, it would be “0010”, instead it needs to be “010”

Thank you so much for your help,

if i implement this code i am getting 002 for every loop. But i dont know what you want to say with the screenshot to be honest. Can you please elab your solution a bit more for me?

kindly note this dynamics


Hi @Novistic

You can get your 3-digit number if you replace Inputvariable+“00”+Count.Tostring with Inputvariable+Count.Tostring(“000”).


please show some screenshots from your current implementation

1 Like

Hi @Novistic ,

We have the Extracted String below as mentioned :


Before using it in the Loop, we convert the String value to a Integer with Zero Suffix +1 like below using an Assign Activity (Outside and before the Loop) :

intValue = Cint("9115681"+"001")

Here, the intValue is of the Type Integer

Next, Inside the For Loop or the While Loop at the End, we can increment it using an Assign Activity again like below :

intValue = intValue+1

If you require the value in String type, just call ToString method on the intValue like below :

1 Like

Hi @Novistic

Here is workflow

Increment.xaml (7.2 KB)


1 Like

Thank you guys for all of your solutions. I tried a mixture of @Pierre_Fleury and @Gokul001

I do have the issue that my workflow doesnt want to count up. Ill explain my workflow to you with some screenshots:

First i extract some string variables from a mail, than i read a excel file and i want to replace placeholders in a word document with data from each row of the datatable.

strNWB is the string variable i want to count up (e.g. 9115681) like i mentioned. The variable which should be created i named strRE (e.g. 9115681001)

Then i need to copy the word file, bc otherwise it would just overwrite my standard word file and replace text wouldnt work anymore:

To differ between the files i would like to have the strRE as filename.

At the end of my loop i save it as pdf (with strRE as filename) and count up:

I also tried your solution @supermanPunch but i get “arithmetic operation resulted in an overflow” as exception, propably because of my strNWB string variable

@Novistic , Please Note that the creation of the strRE should be outside of the For Each Loop and it most probably should be an Integer/BigInt type variable to keep incrementing it’s value.


To avoid this Error, Try Converting your Int32 type variable to Int64 or System.Numerics.BigInt

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