![]() |
Problem mit Countdown
Hallo,
ich programmiere gerade für einen Bekannten einen Countdown bis zum 3.8.2010. Mit diesem Quelltext zeige ich die Tage, Stunden, und Minuten bis zum 3.8.2010 an.
Delphi-Quellcode:
Wie könnte ich jetzt dafür sorgen dass die verbleibenden Sekunden auch angezeigt werden? :wall: Ich bring dass einfach net hin :wall:
procedure TForm1.Timer1Timer(Sender: TObject);
begin Days.Caption := IntToStr(DaysBetween(StrToDate(DateToStr(Now)),StrToDate('03.08.2010'))); Hours.Caption := IntToStr(23 - HoursBetween(StrToTime(TimeToStr(Now)),StrToTime('0'))); Minutes.Caption := IntToStr(59 - MinutesBetween(StrToTime(TimeToStr(Now)),StrToTime(IntToStr((23 - StrToInt(Hours.Caption)))))); // Hier sollen die Angaben für Sekunden rein end; |
Re: Problem mit Countdown
Hallo,
DateUtils kennt auch
Delphi-Quellcode:
Edit: Änderung als neuen Post, damit Du sie net übersiehst ;)
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
begin Result := Trunc(SecondSpan(ANow, AThen)); end; |
Re: Problem mit Countdown
Klappt nicht, denn es zeigt mir die gesammten Sekunden bis um 3.8.2010 an, ich will aber die restsekunden bis zur nächsten Minute
|
Re: Problem mit Countdown
Einfacher wäre noch:
Delphi-Quellcode:
function CountDownStr : String;
const TheDate = '3.8.2010'; var h,m,s,ts : Word; begin DecodeTime(now,h,m,s,hs); Result := IntToStr(DaysBetween(now,StrToDate(TheDate))) + ' Tage' + #13#10 + IntToStr(h) + ' Stunden' + #13#10 + IntToStr(m) + ' Minuten' + #13#10 + IntToStr(s) + ' Sekunden' + #13#10 + IntToStr(ts) + ' Tausendstel' + #13#10 + ); end; |
Re: Problem mit Countdown
Danke, genau so hab ich mir das vorgestellt!!! :thumb:
|
Re: Problem mit Countdown
Probier's mal so
Delphi-Quellcode:
Procedure TForm1.Timer1Timer(Sender: TObject);
Var dtTargetDate: TDateTime; dtDiff: TDateTime; Begin //Das Zieldatum dtTargetDate := StrToDateTime('03.08.2010 00:00:00'); //Differenz zw. Zieldatum und jetzt dtDiff := dtTargetDate - Now; //Zeitelemente in den Labels darstellen lblJahre.Caption := Format('Noch %s Jahre,', [FormatDateTime('yy', dtDiff)]); lblTage.Caption := Format('%s Tage,', [FormatDateTime('dd', dtDiff)]); lblStunden.Caption := Format('%s Stunden,', [FormatDateTime('hh', dtDiff)]); lblMinuten.Caption := Format('%s Minuten,', [FormatDateTime('nn', dtDiff)]); lblSekunden.Caption := Format('und %s Sekunden bis zum %s', [FormatDateTime('ss', dtDiff), DateTimeToStr(dtTargetDate)]); End; |
Re: Problem mit Countdown
Danke, so gehts auch :thumb:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:43 Uhr. |
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-2025 by Thomas Breitkreuz