Scalabium Software

SMReport Autogenerated
Knowledge for your independence'.
Home Delphi and C++Builder tips


#132: I want to add leading zeros for numbers

Sometimes you need add the leading zeros to numbers for formatted printing of report forms or data exporting.

For this task I wrote a small function which return a formatted string (see below the AddLeadingZeros function).

But today I found that standard Format function allow to do a same!
Format('%.10d', [15]) will return '0000000015'

Don't ask me why in Delphi help you'll not find the description of this formatted string or why I didn't find it before:-(

Below is my old function:

function AddLeadingZeros(const Source: string; Len: Integer): string;
var
  i: Integer;
begin
  Result := Source;
  for i := 1 to (Len-Length(Source)) do
    Result := '0' + Result;
end;


Published: November 19, 2001

See also
 
Fast Document Viewer
Excel Reader (dll)
ExcelFile Viewer
SMDBGrid
DBExport tools
Mail parser (ActiveX)
Paradox ActiveX
SMReport
Paradox Password Recovery
ABA Picture Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2026, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising