Ver Mensaje Individual
  #6  
Antiguo 03-05-2007
Avatar de jhonny
jhonny jhonny is offline
Jhonny Suárez
 
Registrado: may 2003
Ubicación: Colombia
Posts: 7.058
Reputación: 30
jhonny Va camino a la famajhonny Va camino a la fama
La función que propuse quedo reducida a esto, gracias a marcos:
Código Delphi [-]
 
type
   TOrientacion = (toLeft, toRight);
 
Function PadString(cVar :String; Caracter :Char; nLen:Integer; Orientacion :TOrientacion):String;
begin
  if Orientacion = toLeft then
    Result:=StringOfChar(Caracter, nLen - Length(cVar))+cVar
  else
    Result:=cVar+StringOfChar(Caracter, nLen - Length(cVar));
end;

Y se puede usar asi, por ejemplo:

Código Delphi [-]
 
ShowMessage(PadString('12345', '0', 10, toLeft));
ShowMessage(PadString('12345', '0', 10, toRight));
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!"

http://www.purodelphi.com/
http://www.nosolodelphi.com/
Responder Con Cita