Autor Beitrag
newbie333
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Sa 27.06.09 22:28 
Hallo,
ich bekomme die Fehlermeldung angezeigt, dass folgendes inkompatible Typen sind:
ausblenden Delphi-Quelltext
1:
if [length(edit1.text)-a] = strtoint('e'then					

leider finde ich den Fehler nicht. :(
Wäre nett wenn ihr mir helfen könntet!
Danke schonmal.


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am So 28.06.2009 um 00:58
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 27.06.09 22:30 
wieso benutzt du eckige Klammern?
Von welchem Typ ist a?
Und wenns kompilieren täte würds abstürzen, da e keine Zahl ist...

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



BeitragVerfasst: Sa 27.06.09 22:37 
ok habs abgeändert:
ausblenden Delphi-Quelltext
1:
b:=[length(edit1.text)-a];					

b und a sind jeweils integer typen.

immer noch falsch :(

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Sa 27.06.09 22:43 
'e' ist aber kein Integer!

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
newbie333 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Sa 27.06.09 22:43 
Hab den Fehler entdeckt und schon wieder ein neues Problem.(Tut mir leid bin Anfänger :()
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.Button1Click(Sender: TObject);
var zaehler,b, a,n:integer;

begin
n:=strtoint(edit1.text);
zaehler:=0;
a:=1;


while a <= length(edit1.text) do
begin
b:=edit1.text[a]; // hier Fehlermeldung: Inkompaible Typen 'Integer' und 'Char'?
if b = 'E' then
inc(zaehler);
inc(a);
end;
label1.caption:=inttostr(zaehler);

end;

end.
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: Sa 27.06.09 22:43 
user profile iconnewbie333 hat folgendes geschrieben Zum zitierten Posting springen:
b:=[length(edit1.text)-a];
Was sollen die eckigen Klammern? Ich sehe kein Array oder so, auf das du damit zugreifen könntest?

// EDIT:
Und bei der Zeile:
Edit1.Text[a] ist ein Buchstabe und keine Zahl. Ord(Edit1.Text[a]) ginge, aber in der nächsten Zeile brauchst du wiederum einen Buchstaben, also wozu überhaupt die Zwischenvariable? :gruebel:
ausblenden Delphi-Quelltext
1:
2:
if Edit1.Text[a] = 'E' then
  ...


// EDIT2:
Und warum überhaupt so kompliziert?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
begin
  zaehler := 0;
  for a := 1 to Length(Edit1.Text) do
    if Edit1.Text[a] = 'E' then
      Inc(zaehler);
  Label1.Caption := IntToStr(zaehler);
end;
newbie333 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Sa 27.06.09 23:25 
weil wir noch keine for-Schleifen können ;)
Aber danke! :)