Autor Beitrag
kinghavi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 18:24 
ich hab noch ne weitere Frage:

Ich benutz ein stringgrid um daten fest zu halten, dabei gibt es dann mehrere werte in einer spalte, jetzt möchte ich diese addieren, dazu habe ich mir folgendes überlegt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
for a:=2 to 16 do
  begin
    for b:=1 to 2 do
      begin
        Summ[a]:=summ[a]+strtoint(form1.stringgrid1.cells[a,b]);
      end;
  end;


das ganze ist in einer procedure die vor der oncreate procedure steht. die procedure wird in der oncreate procedure verwednet und weißt immer einen fehler auf, und zwar blau markiert und in der zeile nach dem im oncreate die procedur aufgerufen wird, brauche hilfe!

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 19.08.06 18:29 
.OnCreate ist zu früh, besser wäre .Loaded.

_________________
Markus Kinzler.
jojo-sp
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

Windows XP Prof, Vista Ultimate & Home Premium, Windows 7
Delphi 7 Enterprise, Delphi 2009
BeitragVerfasst: Sa 19.08.06 18:30 
Wie lautet denn die genaue fehlermeldung?

Ich vermute, er meckert über eine fehlerhafte umwandlung, denn text oder "nichts" kann er nicht berechnen.
Am besten prüfst du ab, ob etwas in dem Feld steht und mit try except (z.B.) kannst du prüfen, ob es eine Zahl ist.

_________________
Ist der Ruf erst ruiniert, lebts sich gänzlich ungeniert...
Wilhelm Busch (1832 - 1908)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 19.08.06 18:40 
Im Zeitpunkt von .onCreate, ist das Grid noch vollständig leer, da kann er nichts berechnen. Wie erwähnt ist .Loaded besser, das da der persistente Inhalt (aus .dfm) schon rekonstruiert ist.

_________________
Markus Kinzler.
kinghavi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Sa 19.08.06 19:53 
hat schon geklappt hab das andersweitg umgeschrieben.