Ver Mensaje Individual
  #3  
Antiguo 25-11-2009
Avatar de MichelH
MichelH MichelH is offline
Miembro
 
Registrado: jul 2005
Ubicación: jalisco mexico
Posts: 44
Reputación: 0
MichelH Va por buen camino
No soy experto y a lo mejor mi respuesta es muy laboriosa pero espero te sirva de ayuda.

Este codigo compara solo letras y numeros de un archivo, no contaria ningun otro caracter, despues guarda el resultado en otra variable que le puedes hacer lo que quieras:

Código Delphi [-]
procedure TFormMain.SpeedButton1Click(Sender: TObject);
var
  vFile, vResultdo     : TStrings;
  i, j, vLetras, vDigitos : Integer;

begin

  // INICIALIZAR VARIABLE TSTRINGS DONDE SE GUARDARA EL RESULTADO
  vResultdo := TStringList.Create;

  // CARGAR ARCHIVO A VARIABLE TSTRINGS
  vFile := TStringList.Create;
  vFile.LoadFromFile('c:\archivo.txt');

  // RECORRER FILAS
  for i:=0 to (vFile.Count-1) do begin
      vLetras  := 0;
      vDigitos := 0;

      // RECORRER LETRAS POR LETRA DE LA FILA
      for j:= 1 to length( vFile[i] ) do begin

          // pARA LAS LETRAS
          if ( (ord(vFile[i][j]) >= 65) and (ord(vFile[i][j]) <= 90) )  or
             ( (ord(vFile[i][j]) >= 97) and (ord(vFile[i][j]) <= 122) ) then
             vLetras := vLetras + 1

          // PARA LOS NUMEROS
          else if (ord(vFile[i][j]) >= 48) and (ord(vFile[i][j]) <= 57) then
             vDigitos := vDigitos + 1;

      end;

      // GUARDAR RESULTADO EN OTRO TSTRINGS
      vResultdo.Add( IntToStr( i ) + ': ' + IntToStr( vLetras ) + ' letras, ' + IntToStr( vDigitos ) + ' digitos' );

  end;

  // MOSTRAR RESULTADO
  ShowMessage( vResultdo.Text );

end;

Saludos!!
__________________
No hay misterios, sólo hay falta de información.
Tampoco hay milagros, sólo hay hechos científicos ignorados
Responder Con Cita