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
 
Mail parser (ActiveX)
Viewer for MS Outlook Messages
SMReport
Metafile Convert
ExcelFile Viewer
DBISAM Viewer
Protected Storage Viewer
SMImport suite
Excel Web-stream
Word Web-stream
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising