--> The "0" Auto number in front of Numbers | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

The "0" Auto number in front of Numbers

| Tuesday, 15 November 2011



Numbering function by adding the number '0 'in front of the numbers. For example the maximum number is 1000, then you have the number 10, then the number 10 was going to set to 0010.

Function declaration:
autonumber_0 function (value, Maksvalue: Integer): String;
var
   sNum: String;
begin
   Result: = '0 ';
   sNum: = IntToStr (value);
   sNum: = StringOfChar ('0 ', Length (IntToStr (Maksvalue)) - Length (sNum)) + sNum;
   Result: = sNum;
end;


Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
var
   i, max: Integer;
begin
   max: = 10;
   for i: = 1 to max do
   begin
     ListBox1.Items.Add (autonumber_0 (i, max) + '. Numbers #' + IntToStr (i));
   end;
end;

Related Posts

No comments: