Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 22-02-2008
[maeyanes] maeyanes is offline
Capo de los Capos
 
Registrado: may 2003
Ubicación: Campeche, México
Posts: 2.732
Poder: 26
maeyanes Va por buen camino
Hola...

Tienes varias opciones... usar un arreglo, o un TList... o hasta un TStringList:

O puedes copiar la lista a otra nueva y ordenarla y luego contar mientras no cambie el número:

Código Delphi [-]
var
  TempList: TStringList;
  OutPutList: TStringList;
  CurrentNumber: string;
  CurrentNumberCount: Integer;
  I: Integer;

begin
  TempList := TStringList.Create;
  // Copiamos la lista del TListBox a una temporal
  TempList.Assign(ListBox1.Items);
  // Ordenamos la lista para hacer más fácil el conteo
  TempList.Sort;  
  OutPutList := TStringList.Create;
  // Inicializamos la variable para obtener el primer número
  CurrentNumber := '';
  for I := 0 to Pred(TempList.Count) do
  begin
    // Si hay cambio de número, guardamos el total de ocurrencias y seguimos con el otro numero
    if CurrentNumber <> TempList[i] then
    begin
      if CurrentNumber <> '' then
        OutPutList.Add(Format('Del número %s hay %d repeticiones', [CurrentNumber, CurrentNumberCount]);
      CurrentNumber := TempList[i];
      CurrentNumberCount := 1
    end
    else
      Inc(CurrentNumberCount)
  end
end;

Este código lo hice al aire y no está probado, por lo que podría tener errores; pero te podría dar una idea de como hacerlo...



Saludos...
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
agregar y/o eliminar items de un listbox a partir de otro listbox Goyo PHP 2 27-09-2007 16:46:30
Registros repetidos enecumene PHP 9 01-02-2007 18:17:04
Recorrer Tabla, contar registro repetidos y escribir totales en otra Tabla Lucas_diaz1810 Conexión con bases de datos 1 25-12-2006 13:04:34
listbox con item repetidos DM2005 Varios 9 07-07-2006 16:18:02
campos repetidos kryna Conexión con bases de datos 12 14-04-2005 17:35:18


La franja horaria es GMT +2. Ahora son las 08:08:34.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi