Einzelnen Beitrag anzeigen

Benutzerbild von Deltachaos
Deltachaos

Registriert seit: 20. Feb 2008
Ort: Berlin
195 Beiträge
 
Delphi 7 Personal
 
#22

Re: Zeichen in Memo ersetzen

  Alt 23. Feb 2008, 11:03
Normalerweise müsste er doch jetzt das a in memo1 durch toll ersätzen und beim klik auf den 2 buttzon das toll durch ein a was es aber nicht tut

Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Memo1: TMemo;
    GroupBox2: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PrintDialog1: TPrintDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

var
key1, key1a, key1b, key2, key2a, key2b, key3, key3a, key3b: string;

procedure _var_;
begin
 key1:= form1.edit1.text;
 key2:= form1.edit2.text;
 key3:= form1.edit3.text;
 key1a := Copy(key1,1,4); //ab dem ersten Zeichen 8 Zeichen kopieren
 key1b := Copy(key1,5,Length(key1)); //ab dem 9. Zeichen den ganzen Rest
end;

procedure code;
begin
  form1.memo1.text := StringReplace(form1.memo1.text, 'a','toll' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'A','toll' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'b','gfhu' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'B','gf#hu' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'c','"bJs' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'C','"b%Js' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'd','/§jT' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'D','/§?jT' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'e','&ast' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'E','&a{st' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'f','g@4[' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'F','g@%4[' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'g','JHG³' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'G','JH²³' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'h','&%gd' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'H','&%%gd' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'i','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'I','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'j','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'J','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'k','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'K','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'l','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'L','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'm','', [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'M','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'n','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'N','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'o','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'O','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'p','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'P','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'q','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Q','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'r','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'R','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 's','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'S','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 't','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'T','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'u','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'U','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'v','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'V','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'w','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'W','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'x','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'X','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'y','(th{G' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Y','(th!{G' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'z','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, 'Y','' , [rfReplaceAll]);
  form1.memo1.text := StringReplace(form1.memo1.text, ' ','H$%³t' , [rfReplaceAll]);
end;

procedure decode;
begin
  form1.memo1.text := StringReplace(form1.memo1.text, 'toll', 'A', [rfReplaceAll]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
     TRY
        Memo1.Lines.Loadfromfile(OpenDialog1.Filename);
     EXCEPT
        ShowMessage ('Fehler beim Laden der Datei!');
     END;
end;



procedure TForm1.Button2Click(Sender: TObject);
begin
  if SaveDialog1.Execute then
     TRY
        Memo1.Lines.SavetoFile(SaveDialog1.Filename);
     EXCEPT
        ShowMessage ('Fehler beim Speichern der Datei!');
     END;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      code;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        code;
        code; //ich weis das es zählschleifen gibt! :-)
      end;
  end;
  begin
    if form1.radiobutton3.checked then
      begin
        code;
        code;
        code;
      end;
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  _var_;
  begin
    if form1.RadioButton1.Checked then
      decode;
  end;
  begin
    if form1.RadioButton2.Checked then
      begin;
        decode;
        decode; //ich weis das es zählschleifen gibt! :-)
      end;
  end;
  begin
    if form1.radiobutton3.checked then
      begin
        decode;
        decode;
        decode;
      end;
  end;
end;

end.
ich binn am ende meines wissens angekommen
Maximilian Ruta
  Mit Zitat antworten Zitat