AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Problem mit Countdown

Problem mit Countdown

Ein Thema von Adrian112 · begonnen am 1. Aug 2007 · letzter Beitrag vom 1. Aug 2007
Antwort Antwort
Adrian112
(Gast)

n/a Beiträge
 
#1

Problem mit Countdown

  Alt 1. Aug 2007, 09:17
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:
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;
Wie könnte ich jetzt dafür sorgen dass die verbleibenden Sekunden auch angezeigt werden? Ich bring dass einfach net hin
  Mit Zitat antworten Zitat
s-off
(Gast)

n/a Beiträge
 
#2

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:12
Hallo,

DateUtils kennt auch
Delphi-Quellcode:
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
begin
  Result := Trunc(SecondSpan(ANow, AThen));
end;
Edit: Änderung als neuen Post, damit Du sie net übersiehst
  Mit Zitat antworten Zitat
Adrian112
(Gast)

n/a Beiträge
 
#3

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:19
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
  Mit Zitat antworten Zitat
Benutzerbild von chrisw
chrisw

Registriert seit: 11. Jan 2005
Ort: Schleswig
193 Beiträge
 
Delphi XE8 Professional
 
#4

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:24
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;
Christian Wahl
me, myself and I, die lustigen Drei !!
  Mit Zitat antworten Zitat
Adrian112
(Gast)

n/a Beiträge
 
#5

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:28
Danke, genau so hab ich mir das vorgestellt!!!
  Mit Zitat antworten Zitat
s-off
(Gast)

n/a Beiträge
 
#6

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:29
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;
  Mit Zitat antworten Zitat
Adrian112
(Gast)

n/a Beiträge
 
#7

Re: Problem mit Countdown

  Alt 1. Aug 2007, 10:34
Danke, so gehts auch
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:24 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz