![]() |
Re: Ratezahl 2 Delphi (leicht)
ok hab ich dieser button mit wo "Rate" draufsteht besitzt jetzt folgendes:
procedure TForm1.Vergleiche(Sender: TObject); begin count := count + 1; Label4.Caption := IntToStr( count); if count = 10 then Label4.Caption := 'Maximale Rateanzahl erreicht, Neue runde?'; BRaten.Enabled := false end; if StrToInt(EEingabe.Text) > Zahl then begin PAntwort.Caption := 'zu groß!'; PAntwort.Color := clred end; begin if StrToInt (EEingabe.Text) < Zahl then begin PAntwort.Caption := 'zu klein'; PAntwort.Color := clred end; begin if StrToInt (EEingabe.Text) = Zahl then PAntwort.Caption := 'Richtig!'; PAntwort.Color := clgreen end // Dies ist ein Kommentar. // Einrückungen verdeutlichen Abhängigkeiten zwischen Anweisungen // und machen den Programm-Code besser lesbar. end; allerdings kommt jetzt ein fehler bei: if StrToInt(EEingabe.Text) > Zahl then Deklaration erwartet aber if gefunden was habe ich falsch gemacht |
Re: Ratezahl 2 Delphi (leicht)
Füge ein begin nach
Delphi-Quellcode:
ein
if count = 10 then
|
Re: Ratezahl 2 Delphi (leicht)
danke... das hab ich jetzt das funktioniert...
Ich weiß das ich etwas bei form1.oncreate einfügen muss damit die Random immer anders ist nur welches befehl? Außerdem brauch ich jetzt ein button der alles zurück setzt für ein neues spiel könnt ihr mir da eventuell denkanstöße geben? |
Re: Ratezahl 2 Delphi (leicht)
Delphi-Quellcode:
Randomize;
|
Re: Ratezahl 2 Delphi (leicht)
eine frage noch außer das mit dem Button für neues spiel
warum wird mein PAntwort Button immer grün auch wenn die zahl zu groß oder zu klein ist normalerweiße sollte er nur grün werden wenn die iengegebene Zahl richtig ist: if StrToInt(EEingabe.Text) > Zahl then begin PAntwort.Caption := 'zu groß!'; PAntwort.Color := clred end; begin if StrToInt (EEingabe.Text) < Zahl then begin PAntwort.Caption := 'zu klein'; PAntwort.Color := clred end; begin if StrToInt (EEingabe.Text) = Zahl then PAntwort.Caption := 'Richtig!'; PAntwort.Color := cllime end |
Re: Ratezahl 2 Delphi (leicht)
Es waren zu viele begins bzw. an der falschen Stelle. Das Setzen der farbe grün wurde deshalb immer ausgeführt.
Delphi-Quellcode:
if StrToInt(EEingabe.Text) > Zahl then
begin PAntwort.Caption := 'zu groß!'; PAntwort.Color := clred end; if StrToInt (EEingabe.Text) < Zahl then begin PAntwort.Caption := 'zu klein'; PAntwort.Color := clred end; if StrToInt (EEingabe.Text) = Zahl then begin PAntwort.Caption := 'Richtig!'; PAntwort.Color := cllime end; |
Re: Ratezahl 2 Delphi (leicht)
Ok thanks das habe ich jetzt
hinbekommen genauso mit dem darstellen der richtigen zahl bei 10 falschen versuchen Label7.Caption := IntToStr ( Zahl); Gibt es ein befehl welcher sagt dass, das Programm kommplet neu geladen werden soll? für "Neues Spiel" |
Re: Ratezahl 2 Delphi (leicht)
Warum das es reicht doch alle Ausgabe die Eingabe und die Zählervariable zurückzusetzen und eine neue Zufallszahl zu ermitteln.
|
Re: Ratezahl 2 Delphi (leicht)
ich hab dort jetzt folgendes stehen bei Onclick beim "Neues SPiel" button
count := 0; BRaten.Enabled := true ; Label4.Caption := '' ; Zahl := Random(100); ScrollBar.Position := Zahl irgendwie klappt es abe rnoch net |
Re: Ratezahl 2 Delphi (leicht)
Was klappt nicht?
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:18 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