Ver Mensaje Individual
  #2  
Antiguo 04-05-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Mantixd,

Cita:
Empezado por Mantixd
...como puedo comparar el texto de 2 memos y mandar a 1 tercer memo el texto diferente...
Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Memo3: TMemo;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   i : Integer;
   L1, L2 : String;
   Pos : Integer;

begin

   Memo3.Clear;

   for i := 0 to Memo1.Lines.Count - 1 do
   begin

       L1 := Memo1.Lines.Strings[i];
       L2 := Memo2.Lines.Strings[i];
       Pos := AnsiPos(L1,L2);

       if (Pos > 0) then
          Delete(L2,Pos,Length(L1));

       Memo3.Lines.Add(TrimLeft(L2));

   end;

end;

end.
El código anterior en Delphi 7 bajo Windows 7 Professional x32, compara línea a línea el texto de TMemo1 con TMemo2 y guarda en TMemo3 el diferencial de TMemo2 menos TMemo1, como se muestra en la imagen:



Espero sea útil

Nelson.
Responder Con Cita