Autor Beitrag
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 12.01.11 17:57 
Das wird mir jetzt zu albern. Hier die Lösung:
ausblenden Delphi-Quelltext
1:
GuthabenAntwort_label.Caption := IntToStr(betrag);					


Wenn du das Rennen wirklich selbst programmiert hast (nicht abgetippt oder Copy und Paste), hätte das für dich aber klar sein müssen.

Für diesen Beitrag haben gedankt: ALF, elundril
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:07 
Dies funktioniert aber trotzdem noch nicht.
Und ja ich habe es selbst programmiert!^^

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
Delphi-Quelltext:

procedure TVCL.Auto1_timerTimer(Sender: TObject);
begin
Randomize;
car1.left := car1.left + Random(10);
If Car1.left >= 620 then
begin
Auto1_timer.enabled := false;
Auto2_timer.enabled := false;
Auto3_timer.enabled := false;
Auto4_timer.enabled := false;
ErgebnisAntwort_label.Caption := 'Gewonnen hat der Ferrari 288 GTO';
betrag:= strtoint(GuthabenAntwort_label.Caption);

If Wetteinsaetze_combobox.text = '10 Euro' then
begin
betrag := betrag - 10 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '20 Euro' then
begin
betrag := betrag -20  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '50 Euro' then
begin
betrag := betrag -50  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '100 Euro' then
betrag := betrag -100;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '200 Euro' then
betrag := betrag -200  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;

Dies ist mein derzeitiger Code.
Ich habe keine Ahnung was dabei nicht stimmt.
Es wird einfach nichts angezeigt im Feld GuthabenAntwort_label, immer nur 0.

Moderiert von user profile iconNarses: Highlight- durch Delphi-Tags ersetzt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 12.01.11 18:11 
Du hast für jedes Auto denselben Code? :shock: Nun gut, es gibt da auch Prozeduren und so, da kannst du den Code auch auslagern, der identisch ist. Dann rufst du nur noch die Prozedur auf.

user profile iconSputyyy hat folgendes geschrieben Zum zitierten Posting springen:
Dies funktioniert aber trotzdem noch nicht.
Und was sagt der Debugger, wenn du zeilenweise durchgehst? Dann siehst du ja schließlich was passiert.
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Mi 12.01.11 18:15 
Ich würde mal sagen das Du aber die 300 erst mal auf Dein label haben must!! Wo passiert den das?

Gruss Alf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!
haentschman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 285
Erhaltene Danke: 33


DX10 Berlin Professional
BeitragVerfasst: Mi 12.01.11 18:18 
selbst dann müßte er negative Zahlen im Label stehen haben...

Ich tippe mal:
1. die 300 nicht richtig ins Label gelegt
2. die ComboBoxeinträge stimmen nicht, deswegen wird nix abgezogen

Der allgemeine Hinweis: GUI und Daten trennen. Niemals mit Captions oder ähnlichem rechnen. Lieber gleich angewöhnen. Umgewöhnen ist schwerer.
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:26 
Doch die Combobox einträge stimmen . ich habe sie gerade nocheinmal kontrolliert.
haentschman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 285
Erhaltene Danke: 33


DX10 Berlin Professional
BeitragVerfasst: Mi 12.01.11 18:30 
- inclusive Breakpoint hier z.B. : betrag := betrag -20 ; ?
- hält der Debugger an, wenn du die Combobox auf 20 Euro stellst ?
- Breakpoint auf die IF Abfrage und schauen wie der Combobox.Text wirklich ausschaut ?
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:34 
Hier ist mein Programm (Grafik ändere ich noch)
Einloggen, um Attachments anzusehen!
haentschman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 285
Erhaltene Danke: 33


DX10 Berlin Professional
BeitragVerfasst: Mi 12.01.11 18:41 
Wie wärs denn mit dem Quelltext... oder befürchtest du, daß Programmteile wiedererkannt werden könnten ? :gruebel:

Ganz im Ernst. Wenn du das selbst gemacht hättest würdest du genau wissen wo das Problem liegt. Sei einfach ehrlich.

Ich mach dann jetzt den Zuschauer... :roll:
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Mi 12.01.11 18:42 
So..
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
If Wetteinsaetze_combobox.text = '10 Euro' then 
begin 
betrag := betrag - 10 ; 
GuthabenAntwort_label.Caption:= IntToStr(betrag); 
end
If Wetteinsaetze_combobox.text = '20 Euro' then 
begin 
betrag := betrag -20 ; 
GuthabenAntwort_label.Caption:= IntToStr(betrag); 
end
If Wetteinsaetze_combobox.text = '50 Euro' then 
begin 
betrag := betrag -50 ; 
GuthabenAntwort_label.Caption:= IntToStr(betrag); 
end
If Wetteinsaetze_combobox.text = '100 Euro' then 
betrag := betrag -100
GuthabenAntwort_label.Caption:= IntToStr(betrag); 
end
If Wetteinsaetze_combobox.text = '200 Euro' then 
betrag := betrag -200 ; 
GuthabenAntwort_label.Caption:= IntToStr(betrag); 
end;


Ich will ja nichts sagen aber guck mal ob da nicht ein oder 2 begins fehlen

Für diesen Beitrag haben gedankt: Sputyyy
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:43 
Ja ich habe es selbst gemacht, sonst wär ja nicht soviel falsch ;DD
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 12.01.11 18:45 
Das forum hier hat 1-2 Benutzer die beweisen das man auch Copy&Paste falsch anwenden kann...

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.

Für diesen Beitrag haben gedankt: Martok
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Mi 12.01.11 18:46 
Bei dem Programm, denke ich aber mal, dass du mehr als nur ein paar Fehler bekommen hast.
Und bei dem Fehler dürfte der Compiler sogar recht genau an die fehlerhafte Stelle sprigen, sodass du direkt erkennen müsstest, was falsch ist.
Hier sind 2 ends zuviel, bzw 2 begins zu wenigs.
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:49 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg, MPlayer;

type
  TVCL = class(TForm)
    Ueberschrift1: TLabel;
    Ueberschrift2: TLabel;
    Start_button: TButton;
    Garage_button: TButton;
    Wetteinsaetze_combobox: TComboBox;
    Wetteinsaetze_label: TLabel;
    Guthaben_label: TLabel;
    GuthabenAntwort_label: TLabel;
    Ergebnis_label: TLabel;
    ErgebnisAntwort_label: TLabel;
    Hintergrund1: TShape;
    Auto1_timer: TTimer;
    Auto2_timer: TTimer;
    Auto3_timer: TTimer;
    Auto4_timer: TTimer;
    Garage1: TShape;
    Garage2: TShape;
    Garage3: TShape;
    Garage4: TShape;
    Linie4: TShape;
    Linie1: TShape;
    Linie2: TShape;
    Linie3: TShape;
    car2: TImage;
    car1: TImage;
    car3: TImage;
    car4: TImage;
    Zeittimer: TTimer;
    Zeitmesser_label: TLabel;
    GeheimerButton: TButton;
    Comicbild: TImage;
    Ziellinie: TImage;
    Box1_bezeichnung: TLabel;
    Box2_bezeichnung: TLabel;
    Box3_bezeichnung: TLabel;
    Box4_bezeichnung: TLabel;
    Siege: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    btn1: TRadioButton;
    btn2: TRadioButton;
    btn3: TRadioButton;
    btn4: TRadioButton;
    Label9: TLabel;
    procedure ZeittimerTimer(Sender: TObject);
    procedure Auto1_timerTimer(Sender: TObject);
    procedure Auto2_timerTimer(Sender: TObject);
    procedure Auto3_timerTimer(Sender: TObject);
    procedure Auto4_timerTimer(Sender: TObject);
    procedure Start_buttonClick(Sender: TObject);
    procedure Garage_buttonClick(Sender: TObject);
    procedure GeheimerButtonClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  VCL: TVCL;
  Betrag : Integer ;

implementation

{$R *.dfm}

procedure TVCL.Auto1_timerTimer(Sender: TObject);
begin
Randomize;
car1.left := car1.left + Random(10);
If Car1.left >= 620 then
begin
Auto1_timer.enabled := false;
Auto2_timer.enabled := false;
Auto3_timer.enabled := false;
Auto4_timer.enabled := false;
ErgebnisAntwort_label.Caption := 'Gewonnen hat der Ferrari 288 GTO';
betrag:= strtoint(GuthabenAntwort_label.Caption);

If Wetteinsaetze_combobox.text = '10 Euro' then
begin
betrag := betrag - 10 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '20 Euro' then
begin
betrag := betrag -20  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '50 Euro' then
begin
betrag := betrag -50  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '100 Euro' then
begin
betrag := betrag -100;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '200 Euro' then
begin
betrag := betrag -200  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
end;
end;

procedure TVCL.Auto2_timerTimer(Sender: TObject);
begin
Randomize;
car2.left := car2.left + Random(10);
If Car2.left >= 620 then
begin
Auto2_timer.enabled := false;
Auto1_timer.Enabled := false;
Auto3_timer.enabled := false;
Auto4_timer.enabled := false;
ErgebnisAntwort_label.Caption := 'Gewonnen hat der Ferrari F40';
betrag:= strtoint(GuthabenAntwort_label.Caption);

If Wetteinsaetze_combobox.text = '10 Euro' then
begin
betrag := betrag - 10;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '20 Euro' then
begin
betrag := betrag -20  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '50 Euro' then
begin
betrag := betrag -50 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '100 Euro' then
begin
betrag := betrag -100 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '200 Euro' then
begin
betrag := betrag -200  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
end;
end;

procedure TVCL.Auto3_timerTimer(Sender: TObject);
begin
Randomize;
car3.left := car3.Left + Random(10);
If Car3.left >= 620 then
begin
Auto3_timer.enabled := false;
Auto1_timer.enabled := false;
Auto2_timer.enabled := false;
Auto4_timer.enabled := false;
ErgebnisAntwort_label.Caption := 'Gewonnen hat der Ferrari F50' ;
betrag:= strtoint(GuthabenAntwort_label.Caption);

If Wetteinsaetze_combobox.text = '10 Euro' then
begin
betrag := betrag - 10 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '20 Euro' then
begin
betrag := betrag -20;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '50 Euro' then
begin
betrag := betrag -50 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '100 Euro' then
begin
betrag := betrag -100 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '200 Euro' then
begin
betrag := betrag -200  ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
end;
end;

procedure TVCL.Auto4_timerTimer(Sender: TObject);
begin
Randomize;
car4.left := car4.left + Random (10);
If Car4.left >= 620 then
begin
Auto4_timer.enabled := false;
Auto1_timer.enabled := false;
Auto2_timer.enabled := false;
Auto3_timer.Enabled := false;
ErgebnisAntwort_label.Caption := 'Gewonnen hat der Ferrari Enzo'   ;
betrag:= strtoint(GuthabenAntwort_label.Caption);

If Wetteinsaetze_combobox.text = '10 Euro' then
begin
betrag := betrag - 10;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '20 Euro' then
begin
betrag := betrag -20 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '50 Euro' then
begin
betrag := betrag -50;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '100 Euro' then
begin
betrag := betrag -100 ;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
If Wetteinsaetze_combobox.text = '200 Euro' then
begin
betrag := betrag -200;
GuthabenAntwort_label.Caption:= IntToStr(betrag);
end;
end;
end;


procedure TVCL.Garage_buttonClick(Sender: TObject);
var
Zahl : Integer ;
begin
Car1.Left := 9;
Car2.Left := 9;
Car3.Left := 9;
Car4.Left := 9;
end;

procedure TVCL.GeheimerButtonClick(Sender: TObject);
begin
ShowMessage(FormatDateTime('dddd, d. mmmm yyyy - hh:mm:ss', Now));
ShowMessage('Viel Glück beim Rennen');
end;


procedure TVCL.Start_buttonClick(Sender: TObject);

begin
Auto1_timer.enabled := true;
Auto2_timer.enabled := true;
Auto3_timer.enabled := true;
Auto4_timer.enabled := true;
end;


procedure TVCL.ZeittimerTimer(Sender: TObject);
var
Zahl : Integer ;
begin
Zahl := StrToInt(Zeitmesser_label.Caption);
Zahl := Zahl + 1;
Zeitmesser_label.Caption := IntToStr(Zahl);
end;

end.


Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Mi 12.01.11 18:54 
Am besten wäre es

1. Den Quelltext einzurücken, das ist so recht unleserlich
2. Die Delphi Tags zu benutzen -> Bei Antwort schreiben unter Bereiche
3. Das ganze Projekt hochzuladen

Lg
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 18:58 
oh okay ..


Zuletzt bearbeitet von Sputyyy am Mi 12.01.11 19:00, insgesamt 1-mal bearbeitet
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Mi 12.01.11 19:00 
und 4. Randomize nur einmal zu benutzen
5. Wie schon gesagt, die Berechnung in eine eigene Procedure auszulagern ( sonst musst du 4 mal ändern )
6. Die globale Variable Betrag als Feld in dein Form zu deklarieren
7. Nur einen Timer zu verwenden
Sputyyy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: Mi 12.01.11 19:10 
ich versteh das nicht ;D
wie soll ich das alles auf einmal in einen Timer bringen .. was ist da eigentlich falsch ( wie gesagt: Bin Anfänger ^^)
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Mi 12.01.11 19:13 
user profile iconSputyyy hat folgendes geschrieben Zum zitierten Posting springen:
ich versteh das nicht ;D
wie soll ich das alles auf einmal in einen Timer bringen .. was ist da eigentlich falsch ( wie gesagt: Bin Anfänger ^^)

Wo ist das Problem, in einer Timer-Procedure alle 4 Autos zu bewegen ?
Dazu fehlt auch noch die Auswertung, ob denn das Auto gewonnen hat, auf das ich gesetzt habe
Und was da falsch ist ? Vollkommen überflüssiger Resourcenverbrauch ( oder kaufst du dir für jeden Wochentag ein extra Auto ?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 13.01.11 09:16 
Dass der Source schlecht ist, darüber muss hier nicht diskutiert werden. Theoretisch sollte es trotzdem funktionieren, soweit ich den Source jetzt angesehen habe.
Wenn der Wert nicht gesetzt wird, dann kann es meiner Ansicht nach nur daran liegen, dass der Vergleich mit dem ComboBox-Text nicht funktioniert.

Irgendwo hat in diesem Thread schon jemand geschrieben, wie man das mit einer Case-Struktur macht. Setz das um und teste das Programm nochmal.

Der Hinweis mit Breakpoints und dem Debugger mal zu testen was dein Programm macht, solltest du ebenfalls dringend beachten.