I am having issues on adding a leading 0 ( Depends how many 0) if the string does now have specific length.( Lets say 12).
If the string has a length of 10 it will add 2 leading 0 in front of the string.
I am half way through it and my if/else condition is not reading the condition.
Help would be appreciated!
2 Likes
21 Likes
I believe something like this will also work.
stringVariable.Concat(stringVariable, β0β)
This option is dynamic for any string variable.
edit: Ah, misread your question.
I put my condition as dt_str.Length <=11 but it wonβt give me an error but it is not working ( in a sense not adding leading 0 even if the number is lessthan 12)
sorry it works now, didnβt see you edited your last post, appreciate you brother!!!
Hi, I suggest using
.PadLeft(12,β0β) like suggested above, cause that will add the zeros up to a total of 12 characters, so no conditions are needed to check the length.
Also, you can just format it with .ToString.
CInt(text).ToString(β000000000000β)
2 Likes