Ver Mensaje Individual
  #1  
Antiguo 08-12-2007
Pedro-Juan Pedro-Juan is offline
Miembro
 
Registrado: ago 2006
Ubicación: Barcelona - España
Posts: 315
Reputación: 18
Pedro-Juan Va por buen camino
Poner puntos a los números mayores de 999 y hasta 1M

//Formatea cadenas de números hasta 1 millón
//Seguro que podeís mejorarla, eso si no existe en delphi...

//LO SIENTO, NO ACIERTO A MOSTRARLA CON LAS ETIQUETAS

Llamada:

Delphi [-]
Form1.label1.Caption := FormatIntMax_1M(nCantidad);

Delphi [-]
function FormatIntMax_1M(Cad: Integer): String; Formatea hasta 1 millón
var CadFormat, CadResul: String;
i: Integer;
begin
CadFormat := Trim(IntToStr(Cad));
CadResul := '';
i := 1;
//Cantidades Entre 0 y 999
if (Length(CadFormat) < 4) then Result := CadFormat; //La deja como está
//Cantidades Entre 1.000 y 9.999
if (Length(CadFormat) = 4) then begin
while (i < 5) do begin
if (i = 1) then begin
CadResul := CadResul + Copy(CadFormat,i,1);
CadResul := (CadResul + '.');
end
else begin
CadResul := (CadResul + Copy(CadFormat,i,1));
end;
i := (i + 1)
end;
Result := CadResul;
end;
//Cantidades Entre 10.000 y 99.999
if (Length(CadFormat) = 5) then begin
while (i < 6) do begin
if (i = 2) then begin
CadResul := CadResul + Copy(CadFormat,i,1);
CadResul := (CadResul + '.');
end
else begin
CadResul := (CadResul + Copy(CadFormat,i,1));
end;
i := (i + 1)
end;
Result := CadResul;
end;
//Cantidades Entre 100.000 y 999.999
if (Length(CadFormat) = 6) then begin
while (i < 7) do begin
if (i = 3) then begin
CadResul := CadResul + Copy(CadFormat,i,1);
CadResul := (CadResul + '.');
end
else begin
CadResul := (CadResul + Copy(CadFormat,i,1));
end;
i := (i + 1)
end;
Result := CadResul;
end;
end;
Responder Con Cita