Pad A Number Field With An Exact Number Of Leading Zeros
October 26, 2005 – 7:43 pmIf you have a number that needs to be padded with leading zeros, this technique does it using Formula language. The same technique (with appropriate syntax changes) can be used in most programming languages.
1 | Padded := @Right( "00000000" + @Text(Number); 8) |
This example returns an eight-character text string (stored in variable “padded” in this example). This string consists of the original value in the Number field, padded with leading zeros to a total length of 8 characters. For example, Number 123 results in Padded 00000123.





One Response to “Pad A Number Field With An Exact Number Of Leading Zeros”
I would consider using @Repeat, makes the changing of the length easier.
PadLength := 8 ;
Padded := @Right( @Repeat( “0â?³ ; PadLength ) + @Text(Number); PadLength )
By Chad Schelfhout on Oct 26, 2005