AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Timer programmieren

Ein Thema von ScrollbarKopf · begonnen am 19. Dez 2007 · letzter Beitrag vom 19. Dez 2007
Antwort Antwort
Seite 1 von 5  1 23     Letzte »    
ScrollbarKopf

Registriert seit: 17. Okt 2007
154 Beiträge
 
#1

Timer programmieren

  Alt 19. Dez 2007, 16:12

Ähm Hallo Leute geht um folgendes habe an den Letzten tagen an einer art lotto gearbeitet jetzt möchte ich gerne einen timer programmieren der alle 48 stunden den gewiiner sagt das er gewonnen aht und den verlierern das sie verloren haben wenn man auf den button ziehung drückt soll er die zahlen aufnehmen sagen ok und wenn die zeit aus ist sagen ob man gewoonen hat hier mein Code.
Delphi-Quellcode:

until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);

edit1.Text := inttostr (a+1);
edit2.Text := inttostr (b+1);
edit3.Text := inttostr (c+1);
edit4.Text := inttostr (d+1);
edit5.Text := inttostr (e+1);
edit6.Text := inttostr (f+1);

richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

end;
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Timer programmieren

  Alt 19. Dez 2007, 16:14
Am Besten als geplanten Task in Windows anlegen
Markus Kinzler
  Mit Zitat antworten Zitat
gmc616

Registriert seit: 25. Jun 2004
Ort: Jena
627 Beiträge
 
Delphi 10.3 Rio
 
#3

Re: Timer programmieren

  Alt 19. Dez 2007, 16:15
Gut. Dann viel Erfolg.

Oder hast etwa ne Frage?? Konnte nämlich keine finden
  Mit Zitat antworten Zitat
ScrollbarKopf

Registriert seit: 17. Okt 2007
154 Beiträge
 
#4

Re: Timer programmieren

  Alt 19. Dez 2007, 16:29
ja habe ne frage habe null ahnung wie ich das machen soll mit dem timer
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: Timer programmieren

  Alt 19. Dez 2007, 16:31
Ein Timer über 48 stunden ist nicht optimal. Sorge dafür das dein Programm in diesem Intervall gestartet wird: "Geplanter Task"
Markus Kinzler
  Mit Zitat antworten Zitat
Nuclear-Ping
(Gast)

n/a Beiträge
 
#6

Re: Timer programmieren

  Alt 19. Dez 2007, 16:34
... oder du nimmst 'ne Variable des Typs TDateTime, speicherst mit Now den Zeitpunkt der letzten Ausführung darin und in einem Timer (der vlt. auf 10sek oder so steht) prüfst du die Variable mit Now gegen. Wenn (Variable + 2) >= Now sind 48h vergangen.

Delphi-Quellcode:
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);
*schauder*

... Dafür hat man dir hier auch schon bessere Lösungen vorgeschlagen.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.139 Beiträge
 
Delphi 12 Athens
 
#7

Re: Timer programmieren

  Alt 19. Dez 2007, 16:52
wegen der 48 Stunden:
Timer ist blöd, weil dann müßte man den Rechner ja die ganzen 48 Stunden an lassen

Da klingt die Idee von mkinzler schon besser.


10 Sekunden? ... nja, bei 2 Tagen Laufzeit reicht doch auch 60 Sekunden ... auf die Sekunde kommt es doch bestimmt nicht an.


jupp schauder und doppelgemoppelt
Delphi-Quellcode:
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and (b<>a) and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and (c<>a) and (c<>b) and (c<>d) and (c<>d) and (c<>f)
and (d<>a) and (d<>b) and (d<>c) and (d<>e) and (d<>f)
and (e<>a) and (e<>b) and (e<>c) and (e<>d) and (e<>f)
and (f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e);
da wird einiges mehrfach ausgewertet.
(a<>b) = (b<>a)
das Rote ist doppelt:
Code:
[color=gray]... hier fehlt wohl was[/color]
until (a<>b) and (a<>c) and (a<>d) and (a<>e) and (a<>f)
and  [color=red](b<>a)[/color] and (b<>c) and (b<>d) and (b<>e) and (b<>f)
and  [color=red](c<>a) and (c<>b)[/color] and (c<>d) and (c<>d) and (c<>f)
and  [color=red](d<>a) and (d<>b) and (d<>c)[/color] and (d<>e) and (d<>f)
and  [color=red](e<>a) and (e<>b) and (e<>c) and (e<>d)[/color] and (e<>f)
and  [color=red](f<>a) and (f<>b) and (f<>c) and (f<>d) and (f<>e)[/color];
man hat also nur verloren, wenn man alle 6 falsch hat?
Delphi-Quellcode:
falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');
wie wäre es z.B. so?
Delphi-Quellcode:
falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche > 0 then showmessage ('Sie haben leider verloren');
Delphi-Quellcode:
falsche := 6 - richtige;
if falsche > 0 then showmessage ('Sie haben leider verloren');
if richtige < 6 then showmessage ('Sie haben leider verloren'); oder gleich zusammen
Delphi-Quellcode:
if richtige = 6 then showmessage ('Sie haben Gewonnen')
else showmessage ('Sie haben leider verloren');
oder ohne Zählvariable:
Delphi-Quellcode:
if (StrToInt(Edit1.text) = StrToInt(Edit7.text))
  and (StrToInt(Edit2.text) = StrToInt(Edit8.text))
  and (StrToInt(Edit3.text) = StrToInt(Edit9.text))
  and (StrToInt(Edit4.text) = StrToInt(Edit10.text))
  and (StrToInt(Edit5.text) = StrToInt(Edit11.text))
  and (StrToInt(Edit6.text) = StrToInt(Edit12.text)) then
begin
  showmessage ('Sie haben Gewonnen');
end else begin
  showmessage ('Sie haben leider verloren');
end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
ScrollbarKopf

Registriert seit: 17. Okt 2007
154 Beiträge
 
#8

Re: Timer programmieren

  Alt 19. Dez 2007, 17:06
himitsu danke für die ideen wegen dem doppelt schreiben ich werde es weg löschen das überflüßige mit deinen beispiel meinst du das man ur verloren hat wenn man alle falsch hat und das wenn man 3 falsch hat mit 3 punkten gewonnen hat oder

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
randomize;
repeat
  a:= random (46);
  b:= random (46);
  c:= random (46);
  d:= random (46);
  e:= random (46);
  f:= random (46);

until(a<>b) and (a<>c) and (a<>d) and (a<>e)
 and (a<>f) and (b<>c) and (b<>d) and (b<>e)
 and (b<>f) and (c<>d) and (c<>e) and (c<>f)
 and (d<>e) and (d<>f) and (e<>f);

edit1.Text := inttostr (a+1);
edit2.Text := inttostr (b+1);
edit3.Text := inttostr (c+1);
edit4.Text := inttostr (d+1);
edit5.Text := inttostr (e+1);
edit6.Text := inttostr (f+1);

richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

falsche :=0;
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then inc (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then inc (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then inc (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then inc (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then inc (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then inc (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.clear;
edit2.clear;
edit3.clear;
edit4.clear;
edit5.clear;
edit6.clear;
edit7.clear;
edit8.clear;
edit9.clear;
edit10.clear;
edit11.clear;
edit12.clear;
end;

end.
  Mit Zitat antworten Zitat
Benutzerbild von vlees91
vlees91

Registriert seit: 19. Apr 2004
843 Beiträge
 
Turbo Delphi für Win32
 
#9

Re: Timer programmieren

  Alt 19. Dez 2007, 17:10
OT: ich hatte dir doch eine so schoene Funktion gemacht, fuer das errechnen von 6 unique Zufallszahlen... Ich bin beledigit, dass du die nicht verwendest
vlees91
  Mit Zitat antworten Zitat
ScrollbarKopf

Registriert seit: 17. Okt 2007
154 Beiträge
 
#10

Re: Timer programmieren

  Alt 19. Dez 2007, 17:12
Kannst die Funktion bitte noaml schreiben kann sein das ich das nciht mitbekommen ahbe
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 5  1 23     Letzte »    


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 01:32 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