Dynamically change String Manipulation

Hi Team,

I was facing one automation problem, can anyone guide us on below -

Basically there is a String for eg =“abc”
We have to change the length of this to 8
eg output we need = “000000abc”

Eg 2 input str = “abcd”
output = “00000abcd”

Can anyone suggest some solution or some good way.

Hi,

you can try str.PadLeft(8,"0"c)

Hi @Sahil_Garg1,

You can specify the number to add to the length of your value to make it dynamic.

value=“abc”

value.PadLeft(value.Length+5,CChar(“0”))

Regards,
MY

1 Like

Hello @Sahil_Garg1

You can refer to the below post.

str_input - input variable
str_output- output variable

str_output = IF(str_input.Length<8,str_input.Insert(0,“0”).ToString,str_input.ToString)

1 Like

stringVar = stringVar.ToString(“D8”)

try this one

1 Like

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