Autor Beitrag
Ulixes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 63

Win Vista Home Premium
Delphi 2009 Professional, XHTML, CSS, PHP
BeitragVerfasst: Mo 24.11.08 18:10 
Hey!

Sorry warscheinlich ganz einfach, aber ich bin betriebsblind...

Ich möchte ganz simpel zählen, wie oft die 1 in der Listbox vorkommt...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure zaehlen ();
var zaehler,i:integer;
begin
for i:= 1 to form5.listbox1.Count - 1 do
begin
if strtoint(form5.ListBox1.Items[i]) = 1 then
zaehler:= zaehler+1;
end;
form5.edit1.Text:= inttostr(zaehler);
end;


Es kommt nach dem Compilieren die Fehlermeldung, dass "0 'kein gültiger Integerwert ist.

Danke für die Hilfe!!!!! :D :D
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Mo 24.11.08 18:19 
Schnelle Hilfe wäre erstmal, den Vergleich ohne Umwandlung zu machen.
ausblenden Delphi-Quelltext
1:
  if form5.ListBox1.Items[i] = '1' then					


Solltest du dann dort schon einen Fehler haben, wirst du es schnell merken.

Ansonsten sehe ich keine Fehler. Es hängt natürlich auch davon ab, was da so in deiner ListBox steht.
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mo 24.11.08 18:22 
"0 " -> eine Null mit nachfolgendem Leerzeichen ist keine Zahl!
Ulixes Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 63

Win Vista Home Premium
Delphi 2009 Professional, XHTML, CSS, PHP
BeitragVerfasst: Mo 24.11.08 18:24 
Cool...

Es funktioniert!!!! :D :D :D :D

VIELEN DANK