Hello,
I have a solution for this problem, but looking to improve it or create more elegant way.
Here is the example:
I have one number which will be maximum of 6 digits.
If the number is 4 digits, I must add two 0 at the start of this document β 001234
If the number is only one digit, I must add five 0 at the start of the documen ->> 000004
I need always to have 6 digit number.
The first solution that come in my mind was this:
Create variable to store the number of digits.
Multiple IF statements where I check the length and
these IF statements will be repetitive until IF Counter = 1
The second one itβs almost the same. I think itβs not good idea, because itβs not even easy readable for the human. In every ELSE statement inside of the IF statement, I put a new IF statement for the next length.
@Veselin_Ganchev
It looks like you want to react on the numbers individually
Have a look on the switch activty
From the understanding of you want to achieve that you want fill up on begin with zeros. So this can be done with the padleft function and you can avoid the nested if else
UPDATED:
And if the goal is to full up a tring to certain length with 0 so it can be done directly with padleft on the string:
First, thanks to all people who send me proposal.
I read all of them and you give me topics to read/understand for new knowledge.
But the most simpler solution was: Number.padleft(6,CChar(β0β)).
Always fill the first digits with zero based on the max length. In this case itβs 6.
I really appreciate every single comment from this topic.