{ Coloca o texto na esquerda
Campos:
Texto = string que será colocada na esquerda;
Qtd = quantidade de caracteres que terá o texto;
Ch = caracter que será preenchido o texto.
Exemplo:
Texto = '15'
Qtd = 4
Ch = 'x'
Result = '15xx'
}
function ColocaTextoEsq(Texto: string; Qtd: integer; Ch: Char): string;
var
x: integer;
begin
if Ch = '' then
Ch := Chr( 32 ) { Espaço }
{endif};
if Length(Texto) > Qtd then
Result := Copy( Texto, 0, Qtd )
else
begin
x := Length( Texto );
for Qtd := x to Qtd-1 do
begin
Texto := Texto + Ch;
end;
Result := Texto;
end
{endif};
end;
{ Coloca o texto na direita
Campos:
Texto = string que será colocada na direita;
Qtd = quantidade de caracteres que terá o texto;
Ch = caracter que será preenchido o texto.
Exemplo:
Texto = '15'
Qtd = 4
Ch = 'x'
Result = 'xx15'
}
function ColocaTextoDir(Texto: string; Qtd: integer; Ch: Char): string;
var
x: integer;
str: string;
begin
if Length(Texto) > Qtd then
Result := Copy( Texto, (Length(Texto)-Qtd) + 1, Length(Texto) )
else
begin
str := '';
for x := Length(Texto) to Qtd - 1 do
begin
str := str + Ch;
end;
Result := str + Texto;
end
{endif};
end;
Espero ter colaborado.