Add dynamic number of leading zeros to string

Hi,

I have a number of IDs that can be various lengths however, I need to add 0s at the start of the ID so that the final length is 14 digits long. For example:
1234 would need to be 00000000001234
456789 would need to be 00000000456789

Is there a simple way to do this?
The theory in my head was to get the length of the initial string given. If its less than 14, add another zero at the start, then check again… but that seems a bit clunky. Is there a nicer way to do this?

Thanks

3 Likes

Hi
This expression would help you resolve this
Stringvariable.padleft(14,CChar(“0”))

Cheers @qwerty1

8 Likes

Perfect! Thanks @Palaniyappan for your quick & simple solution.

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