Registriert seit: 4. Mär 2011
306 Beiträge
Delphi 2010 Professional
|
String prüfen durch eine if anweisung und dann kopieren
15. Sep 2012, 10:27
so geht es nicht !
Delphi-Quellcode:
procedure TForm1.AdvGlowButton6Click(Sender: TObject);
var
s, d, e : String;
begin
//MessageDlg('Einsatznummer Leitstelle'+#10#13+'wirklich ändern ?', mtConfirmation, mbYesNo, 0) = mrYes then begin
if (s = MyTable2.FieldByName('Meldung').Text) and (d = '**') then begin
MyTable2.Edit;
s := MyTable2.FieldByName('Meldung').Text;
d := '**';
Delete(s, 1, Pos(d, s) - 1 + Length(d));
while Pos(#10, s) > 0 do Delete(s, Pos(#10, s), 1);
while Pos(#13, s) > 0 do Delete(s, Pos(#13, s), 1);
s := Trim(s);
MyTable2.FieldByName('E.-Nr:').Text := Copy(MyTable2.FieldByName('Meldung').Text, Length (MyTable2.FieldByName('Meldung').Text+(s))-9, 10)+(s);
MyTable2.Post;
DBedit1.ReadOnly:=false;
end else begin
if d = '*' then begin
MyTable2.Edit;
s := MyTable2.FieldByName('Meldung').Text;
d := '*';
Delete(s, 1, Pos(d, s) - 1 + Length(d));
while Pos(#10, s) > 0 do Delete(s, Pos(#10, s), 1);
while Pos(#13, s) > 0 do Delete(s, Pos(#13, s), 1);
s := Trim(s);
MyTable2.FieldByName('E.-Nr:').Text := Copy(MyTable2.FieldByName('Meldung').Text, Length (MyTable2.FieldByName('Meldung').Text+(s))-9, 10)+(s);
MyTable2.Post;
DBedit1.ReadOnly:=false;
end;
end;
end;
ohne eine if anweisung geht es!
Delphi-Quellcode:
MyTable2.Edit;
s := MyTable2.FieldByName('Meldung').Text;
d := '**';
Delete(s, 1, Pos(d, s) - 1 + Length(d));
while Pos(#10, s) > 0 do Delete(s, Pos(#10, s), 1);
while Pos(#13, s) > 0 do Delete(s, Pos(#13, s), 1);
s := Trim(s);
MyTable2.FieldByName('E.-Nr:').Text := Copy(MyTable2.FieldByName('Meldung').Text, Length (MyTable2.FieldByName('Meldung').Text+(s))-9, 10)+(s);
MyTable2.Post;
DBedit1.ReadOnly:=false;
was muss ich ändern?
|