Buscar

Função para preencher um número com zeros a direita.

Código

//Conteúdo é o numero original a ter os zeros a direita
//Preencher é o caracter o qual será colocado a direita do numero original
//TamString é o tamanho final da string retornada, já com os caracteres a direra
Function fPreencher( const Conteudo : Integer; Const Preencher : String; const TamString : Integer ): String;
Var
qtdFor, i : Integer;
vFull : String;
begin

  qtdFor := Length( IntToStr( Conteudo ) );
  vFull := '';
  If qtdFor >= TamString Then
    result := RightStr( IntToStr( Conteudo ), qtdFor )
  else
    begin
      qtdFor := TamString - QtdFor;
      For i := 1 to qtdFor do
        vFull := vFull + Preencher;
        Result := vFull + IntToStr( Conteudo );
    end;
end;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Componentes
Adicionada dia: 23/04/07
Por: Jurandi Nunes Da Silva
Visualizada: 12600 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009