home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
PROGRAM
/
DELPHI
/
LEADZR
/
LEADZERO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-04-27
|
2KB
|
76 lines
unit Leadzero;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TZeroFill = class(TComponent)
private
{ Private declarations }
function GetStrVal : String;
protected
{ Protected declarations }
FInputVal : LongInt;
FStrVal : String;
FWidth : Integer;
FAlign : String;
public
{ Public declarations }
function FillZeroes(rstSize, inVal : LongInt; aAlign : String ) : String;
published
{ Published declarations }
{Integer value}
property InputVal : LongInt read FInputVal write FInputVal;
{What's returned}
property StrVal : String read GetStrVal;
{The width of the string to return}
property Width : Integer read FWidth write FWidth;
{Justification - must be 'Right' or 'Left'}
property Align : String read FAlign write FAlign;
end;
procedure Register;
implementation
function TZeroFill.GetStrVal : String;
var
I,
endI : Integer;
begin
endI := Width - Length(IntToStr(InputVal));
Result := IntToStr(InputVal);
for I := 1 to endI do
if Align = 'Right' then
Result := '0' + Result
else
Result := Result + '0';
end;
function TZeroFill.FillZeroes(rstSize, inVal : LongInt; aAlign : String ) : String;
begin
InputVal := inVal;
Align := aAlign;
Width := rstSize;
Result := StrVal;
end;
procedure Register;
begin
RegisterComponents('String', [TZeroFill]);
end;
end.