Padding 0 at specific Position

Hello Team,

How could we check if there are 7 character

If yes add 0

Example

  1. 2023089

Here there are 7 character

So final output would be

20230809

Thanks team in advance

Hi @NISHITHA

Try this:

If (inputString.Length = 7)
           inputString = inputString.PadLeft(7, "0"c)

@NISHITHA
Sequence
|-- Assign values in input string
|-- If (Condition: YourInputString.Length = 7)
| |-- Assign (YourInputString = YourInputString + “0”)
|-- Message Box (or any other activity to display or use the result)

Hi @NISHITHA

Check the below one,

- Assign -> Input = "2023089"
- Assign -> Output = If(Input.Length=7,Input.Insert(6,"0"),Input)

Check the below workflow for better understanding,

Hope it helps!!

Thanks @supriya117 for the prompt response

Even I tried this approach but its not inserting 0

Thanks @mkankatala

This approach Works :+1:

1 Like

@NISHITHA

Yeah, I just did check with that. It’s not working truely.
Try this:
output = input.Insert(6, "0")

Counting starts with 0 index so position is 6.

Hey @NISHITHA

If inputString.Length = 7 Then
    inputString = inputString.Substring(0, inputString.Length - 1) & "0" & inputString.Substring(inputString.Length - 1)
End If

It’s my pleasure… @NISHITHA

Happy Automation!!

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