Autor Beitrag
somebody
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 17:51 
Ich habe ein Problem, wie fast jeder.

Bei meinem hier schon bekannten Rechentrainer wollte ich jetzt noch ein fehlerzählen reinbringen, aber dann sagt der:' Inkompatible Typen 'String' und 'Integer'. und das ist der Quelltext.
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Panel2: TPanel;
    Panel4: TPanel;
    Edit1: TEdit;
    Panel5: TPanel;
    Button2: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Panel1: TPanel;
    Panel3: TPanel;
    Panel6: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  zahl2 : integer;
  zahl1 : integer;
  aufgabenart : integer;
  fehler : integer;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
     zahl1 := random(10);
     zahl2 := random(10);
     edit1.text := inttostr(zahl1);
     edit2.text := inttostr(zahl2);
     aufgabenart := random(3);
     edit3.color := clwhite;
     edit3.text := '';

     if
       aufgabenart = 0
     then
         begin
              panel2.caption := '-';
         end;

     if
       aufgabenart = 1
     then
         begin
              panel2.caption := '*';
         end;

     if
       aufgabenart = 2
     then
         begin
              panel2.caption := '+';
         end;
              
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
     randomize;
     panel1.caption := 'Bisher';
     panel6.caption := (strtoint(fehler)); // Hier sagt der das
     panel3.caption := 'Fehler'
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
      if
            aufgabenart = 0
          then
              begin
                   if
                     edit3.text = inttostr(zahl1-zahl2)
                   then
                   begin
                        panel5.caption := 'Richtig';
                        edit3.color := cllime;
                   end
          else
              begin
                    panel5.caption := 'Falsch';
                    edit3.color := clred;
              end;
          end;

          if
            aufgabenart = 1
          then
              begin
                   if
                     edit3.text = inttostr(zahl1*zahl2)
                   then
                   begin
                        panel5.caption := 'Richtig';
                        edit3.color := cllime;
                   end
          else
              begin
                    panel5.caption := 'Falsch';
                    edit3.color := clred;
              end;
          end;

          if
            aufgabenart = 2
          then
              begin
                   if
                     edit3.text = inttostr(zahl1+zahl2)
                   then
                   begin
                        panel5.caption := 'Richtig';
                        edit3.color := cllime;
                   end
          else
              begin
                    panel5.caption := 'Falsch';
                    edit3.color := clred;
              end
          end;

          if
            panel5.caption = 'falsch'
          then
              begin
                   fehler := + 1
              end
end;

end.

Wie mache ich es richtig, das auf panel6 die Fehlerzehl angezeigt wird?

mfg:somebody


Zuletzt bearbeitet von somebody am Mi 09.05.07 16:42, insgesamt 2-mal bearbeitet
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 08.05.07 17:53 
Ohne mir den Quelltext angesehen zu haben: Nimm StrToInt oder IntToStr.
Gib bitte immer die Zeilennummer mit an, sonst wird das ganze zu einem Suchspiel.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 08.05.07 17:53 
IntToStr, nicht StrToInt!

//Edit: JakobWenzel war schneller.
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:00 
Jetzt funzt es nur teilweise, weil da dann immer null steht, auch wenn ich einen fehler gemacht habe.
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:11 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if  
            panel5.caption = 'falsch'  
          then  
              begin  
                   fehler := + 1  
              end


müsste so sein: Panel5.Caption:= 'Falsch'

btw deine formatierung ist kagge, so wirds höllischschwer schon den leichten quelltext zukapiern
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:13 
Dann sagt der bei dem Then darunter :'Ausdruckstyp muss BOOLEAN sein.'

Wie behebe ich das?
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:15 
ahjo mein fehler doppelpunkte natürlich weglassn ;D
If Panel5.Caption = 'Falsch' Then
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:20 
So hatte ich es doch!!!

Wie mache ich es denn nun richtig.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 08.05.07 18:26 
Es geht um den Doppelpunkt vor dem Gleichheitszeichen, der einmal da war und einmal nicht.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:34 
Das weiß ich auch, aber wie bei der gerade geschriebenen version hatte ich es doch am anfang und dann steht da nur eine 0.

Wie mache ich es richtig.
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:34 
nein es geht darum das du falsch geschrieben hast und nicht Falsch
also muss groß sein weil dus immer groß als caption reinschreibst und eben falsch <> Falsch is
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:41 
Geht trotzdem net.
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:45 
ich geh mal von aus du willst das im panel6 ausgeben dann musst dus auch noch hinschreiben das ders dort ausgeben soll
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 18:55 
Das habe ich doch.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.FormCreate(Sender: TObject);
begin
     randomize;
     panel1.caption := 'Bisher';
     panel6.caption := (inttostr(fehler)); //Hier steht das
     panel3.caption := 'Fehler';
end;
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Di 08.05.07 19:24 
das steht im form create das wird aufgerufen wenn die form erstellt wird du musst es aber aufrufen wenn du auf den button klickst

bitte einer den grundlagen link posten hab den ne parat ;D
FSS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 83

Win 7 Professional 64Bit
Delphi 7 PE, Delphi 2005 PE, Turbo Delphi Explorer 2006
BeitragVerfasst: Di 08.05.07 19:30 
Wie Ironwulf schon sagte muss das ganze in die Prozedure von Button2, und zwar so:

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:
procedure TForm1.Button2Click(Sender: TObject);
begin

  if aufgabenart = 0 then begin
    if edit3.text = inttostr(zahl1-zahl2) then begin
      panel5.caption := 'Richtig';
      edit3.color := cllime;
    end else begin
      panel5.caption := 'Falsch';
      edit3.color := clred;
    end;
  end;


  if aufgabenart = 1 then begin
    if edit3.text = inttostr(zahl1*zahl2)then begin
      panel5.caption := 'Richtig';
      edit3.color := cllime;
    end else begin
      panel5.caption := 'Falsch';
      edit3.color := clred;
    end;
  end;


  if aufgabenart = 2 then begin
    if edit3.text = inttostr(zahl1+zahl2)then begin
      panel5.caption := 'Richtig';
      edit3.color := cllime;
    end else begin
      panel5.caption := 'Falsch';
      edit3.color := clred;
    end
end;


if panel5.caption = 'Falsch' then begin  //<-- Hier
  fehler := fehler + 1;                  //<--
  panel6.caption := (inttostr(fehler));  //<--
end;

end;
somebody Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167
Erhaltene Danke: 2



BeitragVerfasst: Mi 09.05.07 16:44 
ah, thx