Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Datum mit Datum austauschen (https://www.delphipraxis.net/112055-datum-mit-datum-austauschen.html)

marabu 18. Apr 2008 14:47

Re: Datum mit Datum austauschen
 
Hallo,

hier noch eine Denkhilfe:

Delphi-Quellcode:
function FindDate(const text: string; var position: Integer): Boolean;
var
  iOffs, iPos: Integer;
  dt: TDateTime;
begin
  iOffs := Pred(Pos(DateSeparator, ShortDateFormat));
  while position > 0 do
  begin
    position := {StrUtils.}PosEx(DateSeparator, text, position);
    if position = 0
      then Break
      else iPos := position - iOffs;
    if TryStrToDate(Copy(text, iPos, Length(ShortDateFormat)), dt)
      then Break
      else position := Succ(position)
  end;
  Result := position > 0;
  position := iPos;
end;
Ich habe so getestet:

Delphi-Quellcode:
procedure TDemoForm.ButtonClick(Sender: TObject);
var
  i, iPos: Integer;
begin
  with Memo do
    for i := 0 to Pred(Lines.Count) do
    begin
      iPos := 1;
      if FindDate(Lines[i], iPos) then
        Lines[i] := {StrUtils.}StuffString(Lines[i], iPos, Length(ShortDateFormat), DateToStr(Now));
    end;
end;
Grüße vom marabu

aaron 18. Apr 2008 15:48

Re: Datum mit Datum austauschen
 
DANKE, DANKE, DANKE!!!
Freundliche Grüße
Aaron


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:19 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz